Sample code for 30+ languages & platforms
PureBasic

Windows Certificate Stores - Find Certificate by Common Name

See more Certificates Examples

Searches the Windows certificate stores for a certificate that matches the specified common name (CN).

Note: This example requires Chilkat v10.0.0 or greater.

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

    success = CkCert::ckLoadByCommonName(cert,"Chilkat Software, Inc.")
    If success = 0
        Debug CkCert::ckLastErrorText(cert)
        CkCert::ckDispose(cert)
        ProcedureReturn
    EndIf

    Debug CkCert::ckSubjectDN(cert)
    Debug "Success."


    CkCert::ckDispose(cert)


    ProcedureReturn
EndProcedure