SOL9 Sample: SignedObject
|
1 Screenshot
2 Source code
/*
* SignedObject.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2009/03/25 This is a simple program to use SOL::SignedObject class and query
// method call of the class.
// The query methdod returns an object of class SOL::CertContext as a
// certificate of the signed file
#include <sol/crypt/SignedObject.h>
#include <sol/crypt/CertContext.h>
void _tmain(int argc, TCHAR** argv)
{
if (argc != 2) {
_tprintf(_T("Usage:\n%s program.exe or some.dll\n"), argv[0]);
return;
}
if (GetFileAttributes(argv[1]) == 0xffffffff) {
_tprintf(_T("File not found:%s\n"), argv[1]);
return;
}
try {
//Signed Object
SignedObject signedObject(argv[1]);
CertContext certContext;
//Query a certificate from the file of fileName
_tprintf(_T("1 Try to signedObject.query(certContext) %s\n"), argv[1]);
if (signedObject.query(certContext) == NO_ERROR) {
_tprintf(_T("2 OK, signedObject.query().\n Got a certificate to %s\n"), argv[1]);
String issuer = "";
String subject= "";
String rdn = "";
String friendly = "";
certContext.getIssuerName(issuer);
certContext.getSubjectName(subject);
certContext.getRDNName(rdn);
certContext.getFriendlyName(friendly);
_tprintf(_T(" Issuer:%s\n"), (const TCHAR*)issuer);
_tprintf(_T(" Subject:%s\n"), (const TCHAR*)subject);
_tprintf(_T(" Friendly:%s\n"), (const TCHAR*)friendly);
_tprintf(_T(" RDN:%s\n"), (const TCHAR*)rdn);
} else {
_tprintf(_T("3 Failed to signedObjec.query().\n '%s' is not signed\n"), argv[1]);
}
} catch (...) {
printf("11 Exception %x\n", GetLastError());
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.