(PureBasic) Convert Certificate from DER to PEM.
Loads a digital certificate from any format, such as DER, and saves to PEM format.
IncludeFile "CkCert.pb"
Procedure ChilkatExample()
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.
; In this case, load a DER format certificate and convert to PEM.
success.i = CkCert::ckLoadFromFile(cert,"qa_data/certs/testCert.cer")
If success <> 1
Debug CkCert::ckLastErrorText(cert)
CkCert::ckDispose(cert)
ProcedureReturn
EndIf
success = CkCert::ckExportCertPemFile(cert,"qa_data/certs/testCert.pem")
If success <> 1
Debug CkCert::ckLastErrorText(cert)
CkCert::ckDispose(cert)
ProcedureReturn
EndIf
Debug "Converted certificate from DER to PEM format."
CkCert::ckDispose(cert)
ProcedureReturn
EndProcedure
|