[VB6 equivalent: PEM_FileFromBinFile]
Dim nRet As Integer
Dim strBinFile As String
Dim strPEMFile As String
Dim strDigest As String
' Input file is a DER-encoded X.509 certificate
' (at 227 bytes, the smallest we could devise)
strBinFile = "smallca.cer"
strPEMFile = "smallca.pem.cer"
' Convert to a PEM file
nRet = Pem.FileFromBinFile(strPEMFile, strBinFile, "CERTIFICATE", 72)
Console.WriteLine("PEM_FileFromBinFile returns " & nRet & " (expecting 0)")
' To prove we did it properly, compute the thumbprint of the two certs
strDigest = X509.CertThumb(strBinFile, HashAlgorithm.Sha1)
If strDigest.Length > 0 Then
Console.WriteLine("SHA-1(der-file)=" & strDigest)
Else
Console.WriteLine("ERROR: computing cert thumb")
End If
strDigest = X509.CertThumb(strPEMFile, HashAlgorithm.Sha1)
If strDigest.Length > 0 Then
Console.WriteLine("SHA-1(pem-file)=" & strDigest)
Else
Console.WriteLine("ERROR: computing cert thumb")
End If
See Also:
Pem.FileFromBinFile Method