Sample code for 30+ languages & platforms
PureBasic

Load CMS PKCS#7 Certificate (.p7b)

See more Certificates Examples

Loads a digital certificate from a Cryptographic Message Syntax Standard PKCS7 (.p7b) file and fetches information about the cert.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkCert.pb"

Procedure ChilkatExample()

    success.i = 0

    cert.i = CkCert::ckCreate()
    If cert.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; LoadFromFile will load virtually any certificate format file.
    ; It will auto-recognize the format and load appropiately.

    success = CkCert::ckLoadFromFile(cert,"/Users/chilkat/testData/cer/chilkat.p7b")
    If success <> 1
        Debug CkCert::ckLastErrorText(cert)
        CkCert::ckDispose(cert)
        ProcedureReturn
    EndIf

    ; DN = "Distinguished Name"
    Debug "SubjectDN:" + CkCert::ckSubjectDN(cert)

    Debug "Common Name:" + CkCert::ckSubjectCN(cert)
    Debug "Issuer Common Name:" + CkCert::ckIssuerCN(cert)

    Debug "Serial Number:" + CkCert::ckSerialNumber(cert)


    CkCert::ckDispose(cert)


    ProcedureReturn
EndProcedure