DataFlex
DataFlex
Supply a Fallback Certificate for S/MIME Verification
See more MIME Examples
Demonstrates the Chilkat Mime.SetVerifyCert method, which supplies a signer-certificate fallback for subsequent signature verification. The only argument is the Cert.
Note: 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: Most signed messages embed the signer's certificate, so
Verify can find it automatically. But some signatures omit it to save space, expecting the recipient to already have it. This method provides that certificate as a fallback so verification can proceed — the S/MIME equivalent of already knowing the sender's public key out of band.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMime
Variant vCert
Handle hoCert
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatMime)) To hoMime
If (Not(IsComObjectCreated(hoMime))) Begin
Send CreateComObject of hoMime
End
Get ComLoadMimeFile Of hoMime "qa_data/signed.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// Supply a signer-certificate fallback for verification. This is useful when the signature does
// not embed the signer certificate and Chilkat cannot otherwise locate it.
Get Create (RefClass(cComChilkatCert)) To hoCert
If (Not(IsComObjectCreated(hoCert))) Begin
Send CreateComObject of hoCert
End
Get ComLoadFromFile Of hoCert "qa_data/signer.cer" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoCert To sTemp1
Showln sTemp1
Procedure_Return
End
Get pvComObject of hoCert to vCert
Get ComSetVerifyCert Of hoMime vCert To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
// Now verify using the supplied certificate.
Get ComVerify Of hoMime To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoMime To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Signature verified using the supplied certificate."
End_Procedure