Sample code for 30+ languages & platforms
Tcl

Get Public Key from Certificate PEM

See more Certificates Examples

Loads a certificate from a PEM file and gets the cert's public key.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set cert [new_CkCert]

set success [CkCert_LoadFromFile $cert "qa_data/certs/someCert.pem"]
if {$success == 0} then {
    puts [CkCert_lastErrorText $cert]
    delete_CkCert $cert
    exit
}

# Get the certificate's public key:
set pubkey [new_CkPublicKey]

CkCert_GetPublicKey $cert $pubkey

puts [CkPublicKey_getPem $pubkey 0]

# OK.. we have the public key which can be used in other Chilkat classes/methods...

delete_CkCert $cert
delete_CkPublicKey $pubkey