Chilkat Online Tools

DescribeCertificateAuthority autoit Example

AWS Private CA

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

$oRest = ObjCreate("Chilkat_9_5_0.Rest")
Local $bSuccess

$oAuthAws = ObjCreate("Chilkat_9_5_0.AuthAws")
$oAuthAws.AccessKey = "AWS_ACCESS_KEY"
$oAuthAws.SecretKey = "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.)
$oAuthAws.Region = "us-west-2"
$oAuthAws.ServiceName = "acm-pca"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://acm-pca.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("acm-pca.us-west-2.amazonaws.com",443,True,True)
If ($bSuccess <> True) Then
    ConsoleWrite("ConnectFailReason: " & $oRest.ConnectFailReason & @CRLF)
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

; 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

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("CertificateAuthorityArn","string")

; The JSON request body created by the above code:

; {
;   "CertificateAuthorityArn": "string"
; }

$oRest.AddHeader("Content-Type","application/x-amz-json-1.1")
$oRest.AddHeader("X-Amz-Target","ACMPrivateCA.DescribeCertificateAuthority")

$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/",$oSbRequestBody,$oSbResponseBody)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

Local $iRespStatusCode = $oRest.ResponseStatusCode
ConsoleWrite("response status code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode <> 200) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oRest.ResponseHeader & @CRLF)
    ConsoleWrite("Response Body:" & @CRLF)
    ConsoleWrite($oSbResponseBody.GetAsString() & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJResp.LoadSb($oSbResponseBody)

; 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

Local $sDirectoryNameCommonName
Local $sDirectoryNameCountry
Local $sDirectoryNameDistinguishedNameQualifier
Local $sDirectoryNameGenerationQualifier
Local $sDirectoryNameGivenName
Local $sDirectoryNameInitials
Local $sDirectoryNameLocality
Local $sDirectoryNameOrganization
Local $sDirectoryNameOrganizationalUnit
Local $sDirectoryNamePseudonym
Local $sDirectoryNameSerialNumber
Local $sDirectoryNameState
Local $sDirectoryNameSurname
Local $sDirectoryNameTitle
Local $sDnsName
Local $sNameAssigner
Local $sPartyName
Local $sIpAddress
Local $sTypeId
Local $sValue
Local $sRegisteredId
Local $sRfc822Name
Local $sUniformResourceIdentifier
Local $sAccessMethodType
Local $sCustomObjectIdentifier

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

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

; {
;   "CertificateAuthority": {
;     "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"
;   }
; }