B4X
B4X
Load Certificate from .cer and Private Key from .pem
See more Certificates Examples
Load a certificate from a .cer and its associated private key from a .pem.Chilkat B4X Downloads
Dim success As Boolean = False
Dim cert As ChilkatCert
cert.Initialize("cert")
success = cert.LoadFromFile("C:/certs_and_keys/Certificate.cer")
If success = False Then
Log(cert.LastErrorText)
Return
End If
Dim sbPem As ChilkatStringBuilder
sbPem.Initialize
success = sbPem.LoadFile("C:/certs_and_keys/PrivateKey.pem", "utf-8")
If success = False Then
Log("Failed to load private key PEM")
Return
End If
success = cert.SetPrivateKeyPem(sbPem.GetAsString)
If success = False Then
Log(cert.LastErrorText)
Return
End If
Log("The certificate and associated private key are now loaded and ready for signing.")