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

PowerBuilder 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
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

 

 

 

(PowerBuilder) Verify a .p7m and get Algorithm Information

Demonstrates how to verify a .p7m and then examine the algorithms used by the signature.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
oleobject loo_Crypt
string ls_InFile
string ls_OutFile
integer li_Success
oleobject loo_Json
integer i
integer li_Count_i
string ls_StrVal
string ls_CertSerialNumber
string ls_CertIssuerCN
string ls_CertIssuerDN
string ls_CertDigestAlgOid
string ls_CertDigestAlgName
string ls_ContentType
string ls_SigningTime
string ls_MessageDigest
string ls_SigningAlgOid
string ls_SignerDigest
integer j
integer li_Count_j
string ls_Oid
string ls_OidName
string ls_Der

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

loo_Crypt = create oleobject
li_rc = loo_Crypt.ConnectToNewObject("Chilkat_9_5_0.Crypt2")
if li_rc < 0 then
    destroy loo_Crypt
    MessageBox("Error","Connecting to COM object failed")
    return
end if

ls_InFile = "qa_data/p7m/brainpoolP256r1.p7m"
ls_OutFile = "qa_output/something.dat"

// Verify and extract the signed data.
li_Success = loo_Crypt.VerifyP7M(ls_InFile,ls_OutFile)
if li_Success = 0 then
    Write-Debug loo_Crypt.LastErrorText
    destroy loo_Crypt
    return
end if

// Examine details about the signature(s)
loo_Json = loo_Crypt.LastJsonData()
loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()

// Sample output

// {
//   "pkcs7": {
//     "verify": {
//       "digestAlgorithms": [
//         "sha256"
//       ],
//       "signerInfo": [
//         {
//           "cert": {
//             "serialNumber": "FFFFE552B302FFFFFF1E34C3ACEB2FFFF",
//             "issuerCN": "The common name of the cert...",
//             "issuerDN": "",
//             "digestAlgOid": "2.16.840.1.101.3.4.2.1",
//             "digestAlgName": "SHA256"
//           },
//           "contentType": "1.2.840.113549.1.7.1",
//           "signingTime": "190409140500Z",
//           "messageDigest": "lQe9If7vZKFf/NlSYu5Esmlw3phVK/RFsbbb1uH73t8=",
//           "signingAlgOid": "1.2.840.10045.4.3.2",
//           "signerDigest": "lQe9If7vZKFf/NlSYu5Esmlw3phVK/RFsbbb1uH73t8=",
//           "authAttr": [
//             {
//               "oid": "1.2.840.113549.1.9.3",
//               "oidName": "contentType"
//             },
//             {
//               "oid": "1.2.840.113549.1.9.5",
//               "oidName": "signingTime"
//             },
//             {
//               "oid": "1.2.840.113549.1.9.52",
//               "oidName": "1.2.840.113549.1.9.52",
//               "der": "MBs ... AwI="
//             },
//             {
//               "oid": "1.2.840.113549.1.9.4",
//               "oidName": "messageDigest"
//             },
//             {
//               "oid": "1.2.840.113549.1.9.16.2.47",
//               "oidName": "signingCertificateV2",
//               "der": "MCYw .. 7PlQ=="
//             },
//             {
//               "oid": "1.2.840.113549.1.9.20",
//               "oidName": "1.2.840.113549.1.9.20"
//             }
//           ]
//         }
//       ]
//     }
//   }
// }

// Code for parsing the above JSON...

i = 0
li_Count_i = loo_Json.SizeOfArray("pkcs7.verify.digestAlgorithms")
do while i < li_Count_i
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("pkcs7.verify.digestAlgorithms[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_Json.SizeOfArray("pkcs7.verify.signerInfo")
do while i < li_Count_i
    loo_Json.I = i
    ls_CertSerialNumber = loo_Json.StringOf("pkcs7.verify.signerInfo[i].cert.serialNumber")
    ls_CertIssuerCN = loo_Json.StringOf("pkcs7.verify.signerInfo[i].cert.issuerCN")
    ls_CertIssuerDN = loo_Json.StringOf("pkcs7.verify.signerInfo[i].cert.issuerDN")
    ls_CertDigestAlgOid = loo_Json.StringOf("pkcs7.verify.signerInfo[i].cert.digestAlgOid")
    ls_CertDigestAlgName = loo_Json.StringOf("pkcs7.verify.signerInfo[i].cert.digestAlgName")
    ls_ContentType = loo_Json.StringOf("pkcs7.verify.signerInfo[i].contentType")
    ls_SigningTime = loo_Json.StringOf("pkcs7.verify.signerInfo[i].signingTime")
    ls_MessageDigest = loo_Json.StringOf("pkcs7.verify.signerInfo[i].messageDigest")
    ls_SigningAlgOid = loo_Json.StringOf("pkcs7.verify.signerInfo[i].signingAlgOid")
    ls_SignerDigest = loo_Json.StringOf("pkcs7.verify.signerInfo[i].signerDigest")
    j = 0
    li_Count_j = loo_Json.SizeOfArray("pkcs7.verify.signerInfo[i].authAttr")
    do while j < li_Count_j
        loo_Json.J = j
        ls_Oid = loo_Json.StringOf("pkcs7.verify.signerInfo[i].authAttr[j].oid")
        ls_OidName = loo_Json.StringOf("pkcs7.verify.signerInfo[i].authAttr[j].oidName")
        ls_Der = loo_Json.StringOf("pkcs7.verify.signerInfo[i].authAttr[j].der")
        j = j + 1
    loop
    i = i + 1
loop

destroy loo_Json

Write-Debug "Success!"


destroy loo_Crypt

 

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