SOL9 Sample: SelfSignedCertificate

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


// SOL9
// 2009/04/17

#include <sol/crypt/SelfSignedCertificate.h>

void _tmain(int argc, TCHAR** argv)
{
  try {
    const TCHAR* fileName = _T("sample.cer");
    
    SelfSignedCertificate ssc;
    const TCHAR* subjectAndIsserName = _T("CN=Future Programming Developer,OU=Terra,C=Earth");

    _tprintf(_T("1 Try to create a self-signed certificate for %s\n"), subjectAndIsserName);

    if (ssc.create(NULL, subjectAndIsserName) == NO_ERROR) {
  
      _tprintf(_T("2 OK, created  a self-signed certificate\n"));
      
      CertInfo certInfo;
      ssc.getCertInfo(certInfo);
      certInfo.dump();

      _tprintf(_T("3 Try to save a self-signed certificate to a file %s\n"), fileName);

      if (ssc.saveToFile(fileName) == NO_ERROR) {
        _tprintf(_T("4 OK saved a self-signed certificate to a file %s\n"), fileName);
      } else {
        _tprintf(_T("5 Failed to save a self-signed certificate to a file %s\n"), fileName);
      }

    } else {
      _tprintf(_T("6 Failed to create a self-signed certificate\n"));

    }
  } catch (...) {
    printf("Exception: %x\n", GetLastError());

  }
}

Last modified: 2 May 2016

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