Sample code for 30+ languages & platforms
Visual Basic 6.0

ZATCA Load Certificate and Private Key from PEM Files

See more ZATCA Examples

Demonstrates how to load a certificate and private key from a pair of PEM files.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

' The LoadFromFile method will automatically detect the file format..
Dim cert As New ChilkatCert
success = cert.LoadFromFile("qa_data/zatca/cert.pem")
If (success <> 1) Then
    Debug.Print cert.LastErrorText
    Exit Sub
End If

Debug.Print cert.SubjectCN

' Load the private key.
Dim privKey As New PrivateKey
success = privKey.LoadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem")
If (success <> 1) Then
    Debug.Print privKey.LastErrorText
    Exit Sub
End If

Debug.Print "Key Type: " & privKey.KeyType

' Associate the private key with the certificate.
success = cert.SetPrivateKey(privKey)
If (success <> 1) Then
    Debug.Print cert.LastErrorText
    Exit Sub
End If

Debug.Print "Success."