Visual FoxPro
Visual FoxPro
Get the Certificate Used for Decryption
See more MIME Examples
Loads a CMS/PKCS #7 encrypted S/MIME message and decrypts it back to the original MIME content.
After a successful decryption, LastDecryptCert loads the certificate(s) actually used into a Cert object, indexed from zero up to NumDecryptCerts minus one.
The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background. Following decryption or security unwrapping, Chilkat records which certificate(s) were used. LastDecryptCert retrieves them so the application can report or verify the identity involved.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loMime
LOCAL lcPfxPassword
LOCAL n
LOCAL loCert
LOCAL i
lnSuccess = 0
loMime = CreateObject('Chilkat.Mime')
lnSuccess = loMime.LoadMimeFile("qa_data/encrypted.eml")
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
CANCEL
ENDIF
* Configure a decryption source and decrypt.
lcPfxPassword = "myPfxPassword"
lnSuccess = loMime.AddPfxSourceFile("qa_data/recipient.pfx",lcPfxPassword)
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
CANCEL
ENDIF
lnSuccess = loMime.Decrypt()
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
CANCEL
ENDIF
* After a successful decryption, load the certificate(s) that were used. The 1st argument is the
* zero-based index and the 2nd is a Cert that receives the certificate.
n = loMime.NumDecryptCerts
loCert = CreateObject('Chilkat.Cert')
FOR i = 0 TO n - 1
lnSuccess = loMime.LastDecryptCert(i,loCert)
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
RELEASE loCert
CANCEL
ENDIF
? "Decrypted with: " + loCert.SubjectCN
NEXT
RELEASE loMime
RELEASE loCert