Archived Forum Post

Index of archived forum posts

Question:

PublicKey LoadFromFile return 0

Jul 21 '16 at 03:35

Using PublicKey metode:

loo_PubKey2.LoadFromFile('C:\Temp\abc.pem')

loo_PubKey2.LastErrorText

return this:

ChilkatLog:
  LoadFromFile(16ms):
    DllDate: Jun 13 2016
    ChilkatVersion: 9.5.0.58
    UnlockPrefix: Anything for 30-day trial
    Architecture: Little Endian; 32-bit
    Language: ActiveX
    VerboseLogging: 1
    loadAnyFormat(16ms):
      loadPem(16ms):
        loadPem2(16ms):
          loadPem(16ms):
            itemType: CERTIFICATE
            addPemItem(16ms):
              itemType: CERTIFICATE
              addCertificate(16ms):
                addCertificate(16ms):
                  certHashEntryB: 356E5DB89EF1B6F9B0779A8E6E64DD96:Certum Level IV CA
                  skiHashKey: SubjectKeyId:5xONbbkk+qlL44K12GhP7G2zxsI=
                --addCertificate
              --addCertificate
            --addPemItem
            No more -----BEGIN's found.
          --loadPem
        --loadPem2
      --loadPem
    --loadAnyFormat
    Failed.
  --LoadFromFile
--ChilkatLog

the file C:\Temp\abc.pem is good.


Answer

It seems you have a certificate, not a public key. Load the Certificate PEM into Chilkat.Cert object, and then call the cert object's method to get the public key. (Consult the online reference documentation..)


Answer

thanks for the tip, this is code in PowerBuilder:

oleobject loo_Cert
oleobject loo_PublicKey

string ls_PubKey_xml

loo_Cert = create oleobject
loo_PublicKey = create oleobject

loo_Cert.ConnectToNewObject("Chilkat_9_5_0.Cert")
loo_PublicKey.ConnectToNewObject("Chilkat_9_5_0.PublicKey")

loo_Cert.LoadFromFile('C:\temp\abc.pem')  //Set path to pem & load to Cert Obj
loo_PublicKey = loo_Cert.ExportPublicKey()//Export Public Key from Cert to PublicKey obj 
ls_PubKey_xml = loo_PublicKey.GetXml()    //get xml
//