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) Get PDF DSS (Document Security Store)

See more PDF Signatures Examples

This example demonstrates how to extract the information from a PDF's DSS (Document Security Store), if a /DSS exists. (Just because a PDF is signed does not mean a /DSS will exists. In fact, the /DSS is typically created at the point of adding the 2nd or greater signature because the /DSS contains LTV (long term validation) information about the previous signature at the time of adding an additional signature.)

Note: This example requires Chilkat v9.5.0.85 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoPdf
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResponseDateTime
    Handle hoResponseDateTime
    Variant vThisUpdate
    Handle hoThisUpdate
    Variant vNextUpdate
    Handle hoNextUpdate
    String sSerial
    String sValidFrom
    String sValidTo
    Boolean iExpired
    String sSubjectCN
    String sSubjectO
    String sIssuerCN
    String sIssuerO
    String sKeyType
    String sKeySize
    String sDer
    String sSubjectOU
    String sSubjectC
    String sIssuerOU
    String sIssuerC
    Integer iResponseStatus
    String sResponseTypeOid
    String sResponseTypeName
    String sResponseResponderIdChoice
    String sResponseResponderKeyHash
    Integer j
    Integer iCount_j
    String sHashOid
    String sHashAlg
    String sIssuerNameHash
    String sIssuerKeyHash
    String sSerialNumber
    Integer iStatus
    Integer i
    Integer iCount_i
    String sTemp1

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

    Get Create (RefClass(cComChilkatPdf)) To hoPdf
    If (Not(IsComObjectCreated(hoPdf))) Begin
        Send CreateComObject of hoPdf
    End

    Get ComLoadFile Of hoPdf "qa_data/pdf/sign_testing_1/helloSigned2.pdf" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoPdf To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Set ComEmitCompact Of hoJson To False

    Get pvComObject of hoJson to vJson
    Get ComGetDss Of hoPdf vJson To iSuccess
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // The document security store contains certificates, OCSP responses, and CRLs.
    // The following JSON is a sample of what the /DSS can contain.
    // Unfortunately, our sample contains /Certs and /OCSPs, but no /CRLs.
    // It's no problem because whatever JSON you get back, you can use the
    // following online tool to generate code to parse.
    // Generate Parsing Code from JSON

    // The code generated by the online tool for this JSON is shown below..

    // {
    //   "/VRI": {
    //     "/EC5BB34CC1F8A0C5FE674427E16E313A08C80808": {}
    //   },
    //   "/Certs": [
    //     {
    //       "serial": "02",
    //       "validFrom": "2011-08-07T19:00:00-05:00",
    //       "validTo": "2021-08-10T23:59:59-05:00",
    //       "expired": false,
    //       "subject": {
    //         "CN": "XYZ Corporation",
    //         "O": "XYZ"
    //       },
    //       "issuer": {
    //         "CN": "XYZ Corporation",
    //         "O": "XYZ"
    //       },
    //       "keyType": "RSA",
    //       "keySize": "2048",
    //       "der": "MIIDz...Q4Zt"
    //     },
    //     {
    //       "serial": "01",
    //       "validFrom": "2011-08-07T19:00:00-05:00",
    //       "validTo": "2021-08-10T23:59:59-05:00",
    //       "expired": false,
    //       "subject": {
    //         "CN": "XYZ Corporation",
    //         "O": "XYZ"
    //       },
    //       "issuer": {
    //         "CN": "XYZ Corporation",
    //         "O": "XYZ"
    //       },
    //       "keyType": "RSA",
    //       "keySize": "2048",
    //       "der": "MIID...jXYFc="
    //     },
    //     {
    //       "serial": "0AA125D6D6321B7E41E405DA3697C215",
    //       "validFrom": "2016-01-07T06:00:00-06:00",
    //       "validTo": "2031-01-07T12:00:00-06:00",
    //       "expired": false,
    //       "subject": {
    //         "CN": "DigiCert SHA2 Assured ID Timestamping CA",
    //         "OU": "www.digicert.com",
    //         "O": "DigiCert Inc",
    //         "C": "US"
    //       },
    //       "issuer": {
    //         "CN": "DigiCert Assured ID Root CA",
    //         "OU": "www.digicert.com",
    //         "O": "DigiCert Inc",
    //         "C": "US"
    //       },
    //       "keyType": "RSA",
    //       "keySize": "2048",
    //       "der": "MIIF...OUg=="
    //     },
    //     {
    //       "serial": "04CD3F8568AE76C61BB0FE7160CCA76D",
    //       "validFrom": "2019-09-30T19:00:00-05:00",
    //       "validTo": "2030-10-17T00:00:00-05:00",
    //       "expired": false,
    //       "subject": {
    //         "CN": "TIMESTAMP-SHA256-2019-10-15",
    //         "O": "DigiCert, Inc.",
    //         "C": "US"
    //       },
    //       "issuer": {
    //         "CN": "DigiCert SHA2 Assured ID Timestamping CA",
    //         "OU": "www.digicert.com",
    //         "O": "DigiCert Inc",
    //         "C": "US"
    //       },
    //       "keyType": "RSA",
    //       "keySize": "2048",
    //       "der": "MIIG...MJtPc="
    //     },
    //     {
    //       "serial": "0CE7E0E517D846FE8FE560FC1BF03039",
    //       "validFrom": "2006-11-09T18:00:00-06:00",
    //       "validTo": "2031-11-10T00:00:00-06:00",
    //       "expired": false,
    //       "subject": {
    //         "CN": "DigiCert Assured ID Root CA",
    //         "OU": "www.digicert.com",
    //         "O": "DigiCert Inc",
    //         "C": "US"
    //       },
    //       "issuer": {
    //         "CN": "DigiCert Assured ID Root CA",
    //         "OU": "www.digicert.com",
    //         "O": "DigiCert Inc",
    //         "C": "US"
    //       },
    //       "keyType": "RSA",
    //       "keySize": "2048",
    //       "der": "MIIDt...FL6Lw8g=="
    //     },
    //     {
    //       "serial": "E4D34D01798BE686424AF7F6F0C3BF41",
    //       "validFrom": "2015-03-24T10:58:16-05:00",
    //       "validTo": "2039-12-31T23:59:59-06:00",
    //       "expired": false,
    //       "subject": {
    //         "CN": "www.xyz.com"
    //       },
    //       "issuer": {
    //         "CN": "www.xyz.com"
    //       },
    //       "keyType": "RSA",
    //       "keySize": "1024",
    //       "der": "MIIB9DCCAWG...UR10lz"
    //     }
    //   ],
    //   "/OCSPs": [
    //     {
    //       "responseStatus": 0,
    //       "responseTypeOid": "1.3.6.1.5.5.7.48.1.1",
    //       "responseTypeName": "ocspBasic",
    //       "response": {
    //         "responderIdChoice": "KeyHash",
    //         "responderKeyHash": "Reuir/SSy4IxLVGLp6chnfNtyA8=",
    //         "dateTime": "20201005173921Z",
    //         "cert": [
    //           {
    //             "hashOid": "1.3.14.3.2.26",
    //             "hashAlg": "SHA-1",
    //             "issuerNameHash": "98S+C0C1w0QzPT+uuU1uONr67FE=",
    //             "issuerKeyHash": "Reuir/SSy4IxLVGLp6chnfNtyA8=",
    //             "serialNumber": "0AA125D6D6321B7E41E405DA3697C215",
    //             "status": 0,
    //             "thisUpdate": "20201005173921Z",
    //             "nextUpdate": "20201012173921Z"
    //           }
    //         ]
    //       }
    //     },
    //     {
    //       "responseStatus": 0,
    //       "responseTypeOid": "1.3.6.1.5.5.7.48.1.1",
    //       "responseTypeName": "ocspBasic",
    //       "response": {
    //         "responderIdChoice": "KeyHash",
    //         "responderKeyHash": "9LbhIB3+Ka7S5GGlsqIlssgXNW4=",
    //         "dateTime": "20201006114501Z",
    //         "cert": [
    //           {
    //             "hashOid": "1.3.14.3.2.26",
    //             "hashAlg": "SHA-1",
    //             "issuerNameHash": "+YYA+KSr7NIxRSxCjUNQo25SyD0=",
    //             "issuerKeyHash": "9LbhIB3+Ka7S5GGlsqIlssgXNW4=",
    //             "serialNumber": "04CD3F8568AE76C61BB0FE7160CCA76D",
    //             "status": 0,
    //             "thisUpdate": "20201006114501Z",
    //             "nextUpdate": "20201013110001Z"
    //           }
    //         ]
    //       }
    //     }
    //   ]
    // }

    Get Create (RefClass(cComChilkatDtObj)) To hoResponseDateTime
    If (Not(IsComObjectCreated(hoResponseDateTime))) Begin
        Send CreateComObject of hoResponseDateTime
    End
    Get Create (RefClass(cComChilkatDtObj)) To hoThisUpdate
    If (Not(IsComObjectCreated(hoThisUpdate))) Begin
        Send CreateComObject of hoThisUpdate
    End
    Get Create (RefClass(cComChilkatDtObj)) To hoNextUpdate
    If (Not(IsComObjectCreated(hoNextUpdate))) Begin
        Send CreateComObject of hoNextUpdate
    End

    Move 0 To i
    Get ComSizeOfArray Of hoJson "/Certs" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "/Certs[i].serial" To sSerial
        Get ComStringOf Of hoJson "/Certs[i].validFrom" To sValidFrom
        Get ComStringOf Of hoJson "/Certs[i].validTo" To sValidTo
        Get ComBoolOf Of hoJson "/Certs[i].expired" To iExpired
        Get ComStringOf Of hoJson "/Certs[i].subject.CN" To sSubjectCN
        Get ComStringOf Of hoJson "/Certs[i].subject.O" To sSubjectO
        Get ComStringOf Of hoJson "/Certs[i].issuer.CN" To sIssuerCN
        Get ComStringOf Of hoJson "/Certs[i].issuer.O" To sIssuerO
        Get ComStringOf Of hoJson "/Certs[i].keyType" To sKeyType
        Get ComStringOf Of hoJson "/Certs[i].keySize" To sKeySize
        Get ComStringOf Of hoJson "/Certs[i].der" To sDer
        Get ComStringOf Of hoJson "/Certs[i].subject.OU" To sSubjectOU
        Get ComStringOf Of hoJson "/Certs[i].subject.C" To sSubjectC
        Get ComStringOf Of hoJson "/Certs[i].issuer.OU" To sIssuerOU
        Get ComStringOf Of hoJson "/Certs[i].issuer.C" To sIssuerC
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "/OCSPs" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComIntOf Of hoJson "/OCSPs[i].responseStatus" To iResponseStatus
        Get ComStringOf Of hoJson "/OCSPs[i].responseTypeOid" To sResponseTypeOid
        Get ComStringOf Of hoJson "/OCSPs[i].responseTypeName" To sResponseTypeName
        Get ComStringOf Of hoJson "/OCSPs[i].response.responderIdChoice" To sResponseResponderIdChoice
        Get ComStringOf Of hoJson "/OCSPs[i].response.responderKeyHash" To sResponseResponderKeyHash
        Get pvComObject of hoResponseDateTime to vResponseDateTime
        Get ComDtOf Of hoJson "/OCSPs[i].response.dateTime" False vResponseDateTime To iSuccess
        Move 0 To j
        Get ComSizeOfArray Of hoJson "/OCSPs[i].response.cert" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "/OCSPs[i].response.cert[j].hashOid" To sHashOid
            Get ComStringOf Of hoJson "/OCSPs[i].response.cert[j].hashAlg" To sHashAlg
            Get ComStringOf Of hoJson "/OCSPs[i].response.cert[j].issuerNameHash" To sIssuerNameHash
            Get ComStringOf Of hoJson "/OCSPs[i].response.cert[j].issuerKeyHash" To sIssuerKeyHash
            Get ComStringOf Of hoJson "/OCSPs[i].response.cert[j].serialNumber" To sSerialNumber
            Get ComIntOf Of hoJson "/OCSPs[i].response.cert[j].status" To iStatus
            Get pvComObject of hoThisUpdate to vThisUpdate
            Get ComDtOf Of hoJson "/OCSPs[i].response.cert[j].thisUpdate" False vThisUpdate To iSuccess
            Get pvComObject of hoNextUpdate to vNextUpdate
            Get ComDtOf Of hoJson "/OCSPs[i].response.cert[j].nextUpdate" False vNextUpdate To iSuccess
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure

 

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