Returns the message digest hash of the PKCS #7 issuerAndSerialNumber value of an X.509 certificate in hexadecimal format.
Public Declare Function X509_HashIssuerAndSN Lib "diCrPKI.dll"
(ByVal strCertFile As String, ByVal strOutput As String,
ByVal nOutChars As Long, ByVal nOptions As Long) As Long
nRet = X509_HashIssuerAndSN(strCertFile, strOutput, nOutChars, nOptions)
long __stdcall X509_HashIssuerAndSN(const char *szCertFile, char *szOutput, long nOutChars, long nOptions);
Returns the number of characters set in szOutput. If nOutChars is zero it returns the maximum number of characters required. C/C++ users should allocate one extra for the terminating NUL character. If an error occurs, it returns a negative error code.
Public Function x509HashIssuerAndSN
(szCertFile As String, Optional nOptions As Long = 0) As String
static std::string dipki::X509::HashIssuerAndSN (const std::string &certFile, HashAlg hashAlg=HashAlg::Sha1)
static X509.cert_hashissuersn(certfilename, hashalg=0)
For the "raw" VBA/C function, the user must allocate an output string buffer szOutput of the required length. Specify a zero nOutChars or an empty string for szOutput to find the required length. ANSI C users must add one to this value when allocating memory.
The certificate may be in binary BER format or base64 PEM format.
Dim nRet As Long Dim strCertName As String Dim strOutput As String * PKI_MAX_HASH_CHARS strCertName = "BobRSASignByCarl.cer" ' Set dir to suit nRet = X509_HashIssuerAndSN(strCertName, strOutput, Len(strOutput), 0) Debug.Print "X509_HashIssuerAndSN returns " & nRet & " for " & strCertName & ": " & Left(strOutput, nRet)
Should result in
X509_HashIssuerAndSN returns 40 for BobRSASignByCarl.cer: 483538bca32adeb3134fe9f74d1ae74cc9ed2e9e
Dim strCertString As String
strCertString = x509ReadStringFromFile("AliceRSASignByCarl.cer")
Debug.Print strCertString
Debug.Print "CertThumb=" & x509CertThumb(strCertString)
strCertString = x509ReadCertStringFromP7Chain("alice_bob_carl_certs.p7c", 3)
Debug.Print strCertString
Debug.Print "CertThumb=" & x509CertThumb(strCertString)
Debug.Print "HashIssuerAndSN=" & x509HashIssuerAndSN(strCertString, PKI_HASH_SHA256)
X509_CertIsValidNow X509_CertThumb