Sample code for 30+ languages & platforms
VB.NET

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 VB.NET Downloads

VB.NET
Dim success As Boolean = False

Dim cert As New Chilkat.Cert
success = cert.LoadFromFile("C:/certs_and_keys/Certificate.cer")
If (success = False) Then
    Debug.WriteLine(cert.LastErrorText)
    Exit Sub
End If


Dim sbPem As New Chilkat.StringBuilder
success = sbPem.LoadFile("C:/certs_and_keys/PrivateKey.pem","utf-8")
If (success = False) Then
    Debug.WriteLine("Failed to load private key PEM")
    Exit Sub
End If


success = cert.SetPrivateKeyPem(sbPem.GetAsString())
If (success = False) Then
    Debug.WriteLine(cert.LastErrorText)
    Exit Sub
End If


Debug.WriteLine("The certificate and associated private key are now loaded and ready for signing.")