![]() |
Chilkat • HOME • Android™ • AutoIt • C • C# • C++ • Chilkat2-Python • CkPython • Classic ASP • DataFlex • Delphi DLL • Go • Java • Node.js • Objective-C • PHP Extension • Perl • PowerBuilder • PowerShell • PureBasic • Ruby • SQL Server • Swift • Tcl • Unicode C • Unicode C++ • VB.NET • VBScript • Visual Basic 6.0 • Visual FoxPro • Xojo Plugin
(PureBasic) Add S/MIME Signature using PFXAdd a digital signature to a MIME message using the certificate + private key from a PFX file.
IncludeFile "CkCert.pb" IncludeFile "CkMime.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. mime.i = CkMime::ckCreate() If mime.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Load a PFX file into a certificate object. cert.i = CkCert::ckCreate() If cert.i = 0 Debug "Failed to create object." ProcedureReturn EndIf pfxFilepath.s = "pfxFiles/something.pfx" pfxPassword.s = "secret" success.i = CkCert::ckLoadPfxFile(cert,pfxFilepath,pfxPassword) If success = 0 Debug CkCert::ckLastErrorText(cert) CkMime::ckDispose(mime) CkCert::ckDispose(cert) ProcedureReturn EndIf success = CkMime::ckSetBodyFromPlainText(mime,"This is the plain-text MIME body.") CkMime::setCkCharset(mime, "utf-8") CkMime::setCkEncoding(mime, "quoted-printable") ; Sign the MIME (adds a PKCS7 detached signature) success = CkMime::ckAddDetachedSignature(mime,cert) If success = 0 Debug CkMime::ckLastErrorText(mime) CkMime::ckDispose(mime) CkCert::ckDispose(cert) ProcedureReturn EndIf ; Save the S/MIME to a file. success = CkMime::ckSaveMime(mime,"/temp/signedMime.txt") If success = 0 Debug CkMime::ckLastErrorText(mime) CkMime::ckDispose(mime) CkCert::ckDispose(cert) ProcedureReturn EndIf Debug "success!" CkMime::ckDispose(mime) CkCert::ckDispose(cert) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.