Chilkat Online Tools

ListCertificateAuthorities DataFlex Example

AWS Private CA

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Variant vAuthAws
    Handle hoAuthAws
    Handle hoJson
    Variant vSbRequestBody
    Handle hoSbRequestBody
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJResp
    String sArn
    Integer iCRLSign
    Integer iDataEncipherment
    Integer iDecipherOnly
    Integer iDigitalSignature
    Integer iEncipherOnly
    Integer iKeyAgreement
    Integer iKeyCertSign
    Integer iKeyEncipherment
    Integer iNonRepudiation
    String sKeyAlgorithm
    String sSigningAlgorithm
    String sCommonName
    String sCountry
    String sDistinguishedNameQualifier
    String sGenerationQualifier
    String sGivenName
    String sInitials
    String sLocality
    String sOrganization
    String sOrganizationalUnit
    String sPseudonym
    String sSerialNumber
    String sState
    String sSurname
    String sTitle
    Integer iCreatedAt
    String sFailureReason
    String sKeyStorageSecurityStandard
    Integer iLastStateChangeAt
    Integer iNotAfter
    Integer iNotBefore
    String sOwnerAccount
    Integer iRestorableUntil
    String sCustomCname
    Integer iEnabled
    Integer iExpirationInDays
    String sS3BucketName
    String sS3ObjectAcl
    Integer iOcspConfigurationEnabled
    String sOcspCustomCname
    String sSerial
    String sStatus
    String sV_Type
    Integer j
    Integer iCount_j
    String sDirectoryNameCommonName
    String sDirectoryNameCountry
    String sDirectoryNameDistinguishedNameQualifier
    String sDirectoryNameGenerationQualifier
    String sDirectoryNameGivenName
    String sDirectoryNameInitials
    String sDirectoryNameLocality
    String sDirectoryNameOrganization
    String sDirectoryNameOrganizationalUnit
    String sDirectoryNamePseudonym
    String sDirectoryNameSerialNumber
    String sDirectoryNameState
    String sDirectoryNameSurname
    String sDirectoryNameTitle
    String sDnsName
    String sNameAssigner
    String sPartyName
    String sIpAddress
    String sTypeId
    String sValue
    String sRegisteredId
    String sRfc822Name
    String sUniformResourceIdentifier
    String sAccessMethodType
    String sCustomObjectIdentifier
    String sNextToken
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1

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

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws
    If (Not(IsComObjectCreated(hoAuthAws))) Begin
        Send CreateComObject of hoAuthAws
    End
    Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY"
    Set ComSecretKey Of hoAuthAws To "AWS_SECRET_KEY"

    // Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
    Set ComRegion Of hoAuthAws To "us-west-2"
    Set ComServiceName Of hoAuthAws To "acm-pca"
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    Get pvComObject of hoAuthAws to vAuthAws
    Get ComSetAuthAws Of hoRest vAuthAws To iSuccess

    // URL: https://acm-pca.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    Get ComConnect Of hoRest "acm-pca.us-west-2.amazonaws.com" 443 True True To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // The following code creates the JSON request body.
    // The JSON created by this code is shown below.

    // Use this online tool to generate code from sample JSON:
    // Generate Code to Create JSON

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateInt Of hoJson "MaxResults" 123 To iSuccess
    Get ComUpdateString Of hoJson "NextToken" "string" To iSuccess
    Get ComUpdateString Of hoJson "ResourceOwner" "string" To iSuccess

    // The JSON request body created by the above code:

    // {
    //   "MaxResults": number,
    //   "NextToken": "string",
    //   "ResourceOwner": "string"
    // }

    Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
    Get ComAddHeader Of hoRest "X-Amz-Target" "ACMPrivateCA.ListCertificateAuthorities" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
    If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
        Send CreateComObject of hoSbRequestBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComEmitSb Of hoJson vSbRequestBody To iSuccess
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestSb Of hoRest "POST" "/" vSbRequestBody vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode
    Showln "response status code = " iRespStatusCode
    If (iRespStatusCode <> 200) Begin
        Showln "Response Header:"
        Get ComResponseHeader Of hoRest To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess

    // The following code parses the JSON response.
    // A sample JSON response is shown below the sample code.

    // Use this online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    Get ComStringOf Of hoJResp "NextToken" To sNextToken
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "CertificateAuthorities" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].Arn" To sArn
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.CRLSign" To iCRLSign
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DataEncipherment" To iDataEncipherment
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DecipherOnly" To iDecipherOnly
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DigitalSignature" To iDigitalSignature
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.EncipherOnly" To iEncipherOnly
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyAgreement" To iKeyAgreement
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyCertSign" To iKeyCertSign
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyEncipherment" To iKeyEncipherment
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.NonRepudiation" To iNonRepudiation
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.KeyAlgorithm" To sKeyAlgorithm
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.SigningAlgorithm" To sSigningAlgorithm
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.CommonName" To sCommonName
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Country" To sCountry
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.DistinguishedNameQualifier" To sDistinguishedNameQualifier
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.GenerationQualifier" To sGenerationQualifier
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.GivenName" To sGivenName
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Initials" To sInitials
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Locality" To sLocality
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Organization" To sOrganization
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.OrganizationalUnit" To sOrganizationalUnit
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Pseudonym" To sPseudonym
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.SerialNumber" To sSerialNumber
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.State" To sState
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Surname" To sSurname
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Title" To sTitle
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].CreatedAt" To iCreatedAt
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].FailureReason" To sFailureReason
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].KeyStorageSecurityStandard" To sKeyStorageSecurityStandard
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].LastStateChangeAt" To iLastStateChangeAt
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].NotAfter" To iNotAfter
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].NotBefore" To iNotBefore
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].OwnerAccount" To sOwnerAccount
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].RestorableUntil" To iRestorableUntil
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.CustomCname" To sCustomCname
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.Enabled" To iEnabled
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.ExpirationInDays" To iExpirationInDays
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.S3BucketName" To sS3BucketName
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.S3ObjectAcl" To sS3ObjectAcl
        Get ComIntOf Of hoJResp "CertificateAuthorities[i].RevocationConfiguration.OcspConfiguration.Enabled" To iOcspConfigurationEnabled
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].RevocationConfiguration.OcspConfiguration.OcspCustomCname" To sOcspCustomCname
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].Serial" To sSerial
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].Status" To sStatus
        Get ComStringOf Of hoJResp "CertificateAuthorities[i].Type" To sV_Type
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.CommonName" To sDirectoryNameCommonName
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Country" To sDirectoryNameCountry
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.DistinguishedNameQualifier" To sDirectoryNameDistinguishedNameQualifier
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.GenerationQualifier" To sDirectoryNameGenerationQualifier
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.GivenName" To sDirectoryNameGivenName
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Initials" To sDirectoryNameInitials
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Locality" To sDirectoryNameLocality
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Organization" To sDirectoryNameOrganization
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.OrganizationalUnit" To sDirectoryNameOrganizationalUnit
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Pseudonym" To sDirectoryNamePseudonym
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.SerialNumber" To sDirectoryNameSerialNumber
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.State" To sDirectoryNameState
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Surname" To sDirectoryNameSurname
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Title" To sDirectoryNameTitle
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DnsName" To sDnsName
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.EdiPartyName.NameAssigner" To sNameAssigner
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.EdiPartyName.PartyName" To sPartyName
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.IpAddress" To sIpAddress
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.OtherName.TypeId" To sTypeId
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.OtherName.Value" To sValue
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.RegisteredId" To sRegisteredId
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.Rfc822Name" To sRfc822Name
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.UniformResourceIdentifier" To sUniformResourceIdentifier
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessMethod.AccessMethodType" To sAccessMethodType
            Get ComStringOf Of hoJResp "CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessMethod.CustomObjectIdentifier" To sCustomObjectIdentifier
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    // A sample JSON response body parsed by the above code:

    // {
    //   "CertificateAuthorities": [
    //     {
    //       "Arn": "string",
    //       "CertificateAuthorityConfiguration": {
    //         "CsrExtensions": {
    //           "KeyUsage": {
    //             "CRLSign": boolean,
    //             "DataEncipherment": boolean,
    //             "DecipherOnly": boolean,
    //             "DigitalSignature": boolean,
    //             "EncipherOnly": boolean,
    //             "KeyAgreement": boolean,
    //             "KeyCertSign": boolean,
    //             "KeyEncipherment": boolean,
    //             "NonRepudiation": boolean
    //           },
    //           "SubjectInformationAccess": [
    //             {
    //               "AccessLocation": {
    //                 "DirectoryName": {
    //                   "CommonName": "string",
    //                   "Country": "string",
    //                   "DistinguishedNameQualifier": "string",
    //                   "GenerationQualifier": "string",
    //                   "GivenName": "string",
    //                   "Initials": "string",
    //                   "Locality": "string",
    //                   "Organization": "string",
    //                   "OrganizationalUnit": "string",
    //                   "Pseudonym": "string",
    //                   "SerialNumber": "string",
    //                   "State": "string",
    //                   "Surname": "string",
    //                   "Title": "string"
    //                 },
    //                 "DnsName": "string",
    //                 "EdiPartyName": {
    //                   "NameAssigner": "string",
    //                   "PartyName": "string"
    //                 },
    //                 "IpAddress": "string",
    //                 "OtherName": {
    //                   "TypeId": "string",
    //                   "Value": "string"
    //                 },
    //                 "RegisteredId": "string",
    //                 "Rfc822Name": "string",
    //                 "UniformResourceIdentifier": "string"
    //               },
    //               "AccessMethod": {
    //                 "AccessMethodType": "string",
    //                 "CustomObjectIdentifier": "string"
    //               }
    //             }
    //           ]
    //         },
    //         "KeyAlgorithm": "string",
    //         "SigningAlgorithm": "string",
    //         "Subject": {
    //           "CommonName": "string",
    //           "Country": "string",
    //           "DistinguishedNameQualifier": "string",
    //           "GenerationQualifier": "string",
    //           "GivenName": "string",
    //           "Initials": "string",
    //           "Locality": "string",
    //           "Organization": "string",
    //           "OrganizationalUnit": "string",
    //           "Pseudonym": "string",
    //           "SerialNumber": "string",
    //           "State": "string",
    //           "Surname": "string",
    //           "Title": "string"
    //         }
    //       },
    //       "CreatedAt": number,
    //       "FailureReason": "string",
    //       "KeyStorageSecurityStandard": "string",
    //       "LastStateChangeAt": number,
    //       "NotAfter": number,
    //       "NotBefore": number,
    //       "OwnerAccount": "string",
    //       "RestorableUntil": number,
    //       "RevocationConfiguration": {
    //         "CrlConfiguration": {
    //           "CustomCname": "string",
    //           "Enabled": boolean,
    //           "ExpirationInDays": number,
    //           "S3BucketName": "string",
    //           "S3ObjectAcl": "string"
    //         },
    //         "OcspConfiguration": {
    //           "Enabled": boolean,
    //           "OcspCustomCname": "string"
    //         }
    //       },
    //       "Serial": "string",
    //       "Status": "string",
    //       "Type": "string"
    //     }
    //   ],
    //   "NextToken": "string"
    // }


End_Procedure