Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Duplicate OpenSSL smime CommandDemonstrates how to duplicate an OpenSSL smime command to sign a text file using cert + key.
LOCAL lcCertPath LOCAL lcPrivateKeyPath LOCAL lcPassword LOCAL lcDataFile LOCAL loCert LOCAL lnSuccess LOCAL loPrivKey LOCAL loBd LOCAL loCrypt LOCAL loSbPem * This requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * This example duplicates the following OpenSSL command: * * smime -sign -in helloWorld.txt -signer cert.pem -inkey my.key -passin pass:test1234 -outform PEM -out helloWorldSigned.pem lcCertPath = "qa_data/cert.pem" lcPrivateKeyPath = "qa_data/my.key" lcPassword = "test1234" lcDataFile = "qa_data/helloWorld.txt" * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Cert') loCert = CreateObject('Chilkat.Cert') lnSuccess = loCert.LoadFromFile(lcCertPath) IF (lnSuccess <> 1) THEN ? loCert.LastErrorText RELEASE loCert CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.PrivateKey') loPrivKey = CreateObject('Chilkat.PrivateKey') lnSuccess = loPrivKey.LoadEncryptedPemFile(lcPrivateKeyPath,lcPassword) IF (lnSuccess <> 1) THEN ? loPrivKey.LastErrorText RELEASE loCert RELEASE loPrivKey CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.BinData') loBd = CreateObject('Chilkat.BinData') lnSuccess = loBd.LoadFile(lcDataFile) IF (lnSuccess <> 1) THEN ? "Failed to load " + lcDataFile RELEASE loCert RELEASE loPrivKey RELEASE loBd CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Crypt2') loCrypt = CreateObject('Chilkat.Crypt2') lnSuccess = loCrypt.SetSigningCert2(loCert,loPrivKey) IF (lnSuccess <> 1) THEN ? loCrypt.LastErrorText RELEASE loCert RELEASE loPrivKey RELEASE loBd RELEASE loCrypt CANCEL ENDIF lnSuccess = loCrypt.OpaqueSignBd(loBd) IF (lnSuccess <> 1) THEN ? loCrypt.LastErrorText RELEASE loCert RELEASE loPrivKey RELEASE loBd RELEASE loCrypt CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbPem = CreateObject('Chilkat.StringBuilder') loSbPem.AppendLine("-----BEGIN PKCS7-----",1) loSbPem.Append(loBd.GetEncoded("base64_mime")) loSbPem.AppendLine("-----END PKCS7-----",1) loSbPem.WriteFile("helloWorldSigned.pem","utf-8",0) ? loSbPem.GetAsString() * Sample output: * -----BEGIN PKCS7----- * MIINxAYJKoZIhvcNAQcCoIINtTCCDbECAQExCzAJBgUrDgMCGgUAMBoGCSqGSIb3DQEHAaANBAtI * ZWxsbyBXb3JsZKCCC0owggYQMIID+KADAgECAhBNlCwQ1DvglAnFgS06KwZPMA0GCSqGSIb3DQEB * DAUAMIGIMQswCQYDVQQGEwJVUzETMBEGA1UECBMKTmV3IEplcnNleTEUMBIGA1UEBxMLSmVyc2V5 * IENpdHkxHjAcBgNVBAoTFVRoZSBVU0VSVFJVU1QgTmV0d29yazEuMCwGA1UEAxMlVVNFUlRydXN0 * IFJTQSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xODExMDIwMDAwMDBaFw0zMDEyMzEyMzU5 * NTlaMIGWMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQH * EwdTYWxmb3JkMRgwFgYDVQQKEw9TZWN0aWdvIExpbWl0ZWQxPjA8BgNVBAMTNVNlY3RpZ28gUlNB * IENsaW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loCert RELEASE loPrivKey RELEASE loBd RELEASE loCrypt RELEASE loSbPem |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.