Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) Create PKCS7 Attached/Opaque Signature (S/MIME)

Create an S/MIME message with a PKCS7 attached/opaque signature.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoMime
    Variant vCert
    Handle hoCert
    String sPfxFilepath
    String sPfxPassword
    Boolean iSuccess
    String sTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatMime)) To hoMime
    If (Not(IsComObjectCreated(hoMime))) Begin
        Send CreateComObject of hoMime
    End

    // Load a certificate w/ private key for signing.
    // There are many ways of getting a certificate object:
    // from a pfx file, from .cer and private-key files, from the
    // Windows registry-based certificate stores, etc.
    // Load a PFX file into a certificate object.
    Get Create (RefClass(cComChilkatCert)) To hoCert
    If (Not(IsComObjectCreated(hoCert))) Begin
        Send CreateComObject of hoCert
    End
    Move "pfxFiles/something.pfx" To sPfxFilepath
    Move "secret" To sPfxPassword
    Get ComLoadPfxFile Of hoCert sPfxFilepath sPfxPassword To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoCert To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Create a very simple MIME message to be signed:
    Get ComAddHeaderField Of hoMime "Subject" "This is a test" To iSuccess
    Get ComAddHeaderField Of hoMime "MyCustomHeader" "abc123" To iSuccess
    Set ComContentType Of hoMime To "text/plain"
    Send ComSetBody To hoMime "This is a plain-text body."

    // Examine the MIME prior to signing:
    Showln "--- MIME prior to signing ---"
    Get ComGetMime Of hoMime To sTemp1
    Showln sTemp1

    // The MIME prior to signing looks like this:
    // -------------------------------------------------------------------------------

    // Subject: This is a test
    // MyCustomHeader: abc123
    // Content-Type: text/plain
    // 
    // This is a plain-text body.

    // -------------------------------------------------------------------------------

    // The default hash algorithm used in the signing process is "SHA1".
    // To change it, set the SigningHashAlg property:
    Set ComSigningHashAlg Of hoMime To "SHA256"

    // Convert the MIME to PKCS7 signed-data.
    Get pvComObject of hoCert to vCert
    Get ComConvertToSigned Of hoMime vCert To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMime To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Examine the signed MIME
    Showln "--- MIME converted to PKCS7 signed-data ---"
    Get ComGetMime Of hoMime To sTemp1
    Showln sTemp1

    // The MIME after signing looks like this:
    // -------------------------------------------------------------------------------

    // Subject: This is a test
    // MyCustomHeader: abc123
    // Content-Disposition: attachment; filename="smime.p7m"
    // Content-Transfer-Encoding: base64
    // Content-Type: application/x-pkcs7-mime;
    //  name="smime.p7m"; smime-type="signed-data"
    // 
    // MIIObAYJKoZIhvcNAQcCoIIOXTCCDlkCAQExDzANBglghkgBZQMEAgEFADB2BgkqhkiG9w0BBwGg
    // aQRnU3ViamVjdDogVGhpcyBpcyBhIHRlc3QNCk15Q3VzdG9tSGVhZGVyOiBhYmMxMjMNCkNvbnRl
    // bnQtVHlwZTogdGV4dC9wbGFpbg0KDQpUaGlzIGlzIGEgcGxhaW4tdGV4dCBib2R5LqCCCaAwggRm
    // MIIDTqADAgECAhBEvgyLUAAktBHTNi3gs18bMA0GCSqGSIb3DQEBBQUAMIGVMQswCQYDVQQGEwJV
    // UzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYDVQQKExVUaGUgVVNF
    // UlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cudXNlcnRydXN0LmNvbTEdMBsGA1UE
    // AxMUVVROLVVTRVJGaXJzdC1PYmplY3QwHhcNOTkwNzA5MTgzMTIwWhcNMTkwNzA5MTg0MDM2WjCB
    // lTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEeMBwG
    // A1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8vd3d3LnVzZXJ0cnVz
    // dC5jb20xHTAbBgNVBAMTFFVUTi1VU0VSRmlyc3QtT2JqZWN0MIIBIjANBgkqhkiG9w0BAQEFAAOC
    // AQ8AMIIBCgKCAQEAzqqBP6OjYXiqMQBVlRGeJw8fHN86m4JoMMBKYR3xLw76vnn3pSPvVVGWhM3b
    // 47luPjHYCiBnx/TZv5TrRwQ+As4qol2HBAn2MJ0Yipeyqhz8QdKhNsv7PZG659lwNfrk55DDm6Ob
    // 0zz1Epl3sbcJ4GjmHLjzlGOIamr+C3bJvvQi5Ge5qxped8GFB90NbL/uBsd3akGepw/X++6UF7f8
    // hb6kq8QcMd3XttHk8O/fFo+yUpPXodSJoQcuv+EBEkIeGuHYlTTbZHko/7ouEcLl6FuSSPtHC8Js
    // 2q0yg0HzpeVBcP1lkG36+lHE+b2WKxkELNNtp9zwf2+DZeJqq4eGdQIDAQABo4GvMIGsMAsGA1Ud
    // DwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTa7WR0FJwUPKvdmam9WyhNizzJ2DBC
    // BgNVHR8EOzA5MDegNaAzhjFodHRwOi8vY3JsLnVzZXJ0cnVzdC5jb20vVVROLVVTRVJGaXJzdC1P
    // YmplY3QuY3JsMCkGA1UdJQQiMCAGCCsGAQUFBwMDBggrBgEFBQcDCAYKKwYBBAGCNwoDBDANBgkq
    // hkiG9w0BAQUFAAOCAQEACB9SsTdEeNv9zrnalZaYqlVkgLVaQN0hpcXB818sTMhHWmnq6PA1NfTQ
    // JfPIpqSHSr0bsXMIvdTDyrY1u1mGdzHNp4AUrhPv/LFI+WslJS1RtixtRcGYyIpWXT7uQ04+ayeO
    // 0DpLhQtf0+1qp3XL0VqHLzl1E1pysAKBn77wD4RUIGJsadThTcYNmUMBDRKWjHidv1CisUSqas8X
    // es9vD9T4JFVf8DQWSWY+UEbJY3E4MWK4YrnzU61stSuiEqoZTwnaXueTxo4UCP7wMIAYoIaFTch9
    // 14sD/m7V950WrJIsoCPlnJFSH5TfF5Rzw7PBwXEFIAB4vRNSHag+zQAfyDCCBTIwggQaoAMCAQIC
    // EQDm/GiUo2tiCnVnsAEgJ0r7MA0GCSqG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wYBBQUHAwMw
    // EQYJYIZIAYb4QgEBBAQDAgQQMEYGA1UdIAQ/MD0wOwYMKwYBBAGyMQECAQMCMCswKQYIKwYBBQUH
    // AgEWHWh0dHBzOi8vc2VjdXJlLmNvbW9kby5uZXQvQ1BTMEIGA1UdHwQ7MDkwN6A1oDOGMWh0dHA6
    // Ly9jcmwudXNlcnRydXN0LmNvbS9VVE4tVVNFUkZpcnN0LU9iamVjdC5jcmwwNAYIKwYBBQUHAQEE
    // KDAmMCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5jb21vZG9jYS5jb20wIAYDVR0RBBkwF4EVYWRt
    // aW5AY2hpbGthdHNvZnQuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQAP/2IpG75SHSFFqjHqvCXy0n0O
    // MTQk2IexnIUBlF7wm0oZquXBG2GlOPd9IXNr7k3wf4G+nZ6rgit6slVT1VxZS8RzqhGT3ZRTa2ud
    // dSqJyKxxrqdBJMY/WWaWVtCSU74AKAAm/ONwD1Zz39IZ2Mr8ApXn2LnZy4ZgI3hZnVR8I92/sppl
    // +NKWr0iMBpcz2KEwXZ5lrS5/4qRFlY+LQgRBFnjoM9WDW1lGEqeHFQQ/dqyrNiRAp+l7OzPBS4aM
    // nfxS+Yj/blpnuW41dVi9TJTXozRwiHzQ41FfrkJMD4JZULc539SK1EU1cYMl13x3JODHlng2IrjZ
    // pCKrFCsSCP2BMYIEJTCCBCECAQEwgaswgZUxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJVVDEXMBUG
    // A1UEBxMOU2FsdCBMYWtlIENpdHkxHjAcBgNVBAoTFVRoZSBVU0VSVFJVU1QgTmV0d29yazEhMB8G
    // A1UECxMYaHR0cDovL3d3dy51c2VydHJ1c3QuY29tMR0wGwYDVQQDExRVVE4tVVNFUkZpcnN0LU9i
    // amVjdAIRAOb8aJSja2IKdWewASAnSvswDQYJYIZIAWUDBAIBBQCgggJKMBgGCSqGSIb3DQEJAzEL
    // BgkqhkiG9w0BBwEw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nUT2eYxxYBPtX9X6DQSKh3+iLNz0
    // sx89fluXIoqWONjR/XyN8zYd6WtEqMMwY6HQPAblFEuMPHZIhC0h/hfGAVisKLmh
    // 

    // ------------------------------------------------------------------------------


End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.