SOL9 Sample: CertSelectionDialog

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * CertSelectionDialog.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2009/03/18
// 2012/06/21

#include <sol/crypt/CryptServiceProvider.h>
#include <sol/crypt/CertSystemStore.h>
#include <sol/crypt/CertContext.h>
#include <sol/crypt/CertSelectionDialog.h>
#include <sol/Locale.h>

void _tmain(int argc, TCHAR** argv)
{
  Locale locale;

  try {
    CryptServiceProvider csp;

    CertSystemStore ca(csp, _T("CA"));

    CertSelectionDialog certSelDlg(ca);

    PCCERT_CONTEXT pContext = certSelDlg.show();
    if (pContext) {
      _tprintf(_T("OK, selection a certificate\n"));
      CertContext cert(pContext);

      TCHAR name[MAX_PATH];

      cert.getName(name, SizeOf(name));  //2012/06/21
      _tprintf(_T("Name:\n\t%s\n"), name);

      TCHAR issuer[MAX_PATH];

      cert.getIssuerName(issuer, SizeOf(issuer)); //2012/06/21
      _tprintf(_T("Issuer:\n\t%s\n"), issuer);

      TCHAR friendlyName[MAX_PATH];
      cert.getFriendlyName(friendlyName, SizeOf(friendlyName)); //2012/06/21  
      _tprintf(_T("FriendlyName:\n\t%s\n"), friendlyName);

      TCHAR rdnName[MAX_PATH];
      cert.getRDNName(rdnName, SizeOf(rdnName)); //2012/06/21
      _tprintf(_T("RDNName:\n\t%s\n"), rdnName);

      TCHAR email[MAX_PATH];
      cert.getEMail(email, SizeOf(email)); //2012/06/21
      _tprintf(_T("Email:\n\t%s\n"), email);

      TCHAR cn[MAX_PATH];

      cert.getCNName(cn, SizeOf(cn)); //2012/06/21
      _tprintf(_T("CN:\n\t%s\n"), cn);


    } else {
      _tprintf(_T("NG, Canceled a selection\n"));
    }
    
  } catch (...) {

  }
}

Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.