Sample code for 30+ languages & platforms
PureBasic

Transition from Cert.GetCertChain to Cert.BuildCertChain

Provides instructions for replacing deprecated GetCertChain method calls with BuildCertChain.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkCertChain.pb"
IncludeFile "CkCert.pb"

Procedure ChilkatExample()

    success.i = 0

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

    ; ------------------------------------------------------------------------
    ; The GetCertChain method is deprecated:

    certchainObj.i = CkCert::ckGetCertChain(cert)
    If CkCert::ckLastMethodSuccess(cert) = 0
        Debug CkCert::ckLastErrorText(cert)
        CkCert::ckDispose(cert)
        ProcedureReturn
    EndIf

    ; ...
    ; ...

    CkCertChain::ckDispose(certchainObj)

    ; ------------------------------------------------------------------------
    ; Do the equivalent using BuildCertChain.
    ; Your application creates a new, empty CertChain object which is passed 
    ; in the last argument and filled upon success.

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

    success = CkCert::ckBuildCertChain(cert,certchainOut)
    If success = 0
        Debug CkCert::ckLastErrorText(cert)
        CkCert::ckDispose(cert)
        CkCertChain::ckDispose(certchainOut)
        ProcedureReturn
    EndIf



    CkCert::ckDispose(cert)
    CkCertChain::ckDispose(certchainOut)


    ProcedureReturn
EndProcedure