Chilkat Online Tools

DescribeCertificateAuthority Foxpro Example

AWS Private CA

LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcDirectoryNameCommonName
LOCAL lcDirectoryNameCountry
LOCAL lcDirectoryNameDistinguishedNameQualifier
LOCAL lcDirectoryNameGenerationQualifier
LOCAL lcDirectoryNameGivenName
LOCAL lcDirectoryNameInitials
LOCAL lcDirectoryNameLocality
LOCAL lcDirectoryNameOrganization
LOCAL lcDirectoryNameOrganizationalUnit
LOCAL lcDirectoryNamePseudonym
LOCAL lcDirectoryNameSerialNumber
LOCAL lcDirectoryNameState
LOCAL lcDirectoryNameSurname
LOCAL lcDirectoryNameTitle
LOCAL lcDnsName
LOCAL lcNameAssigner
LOCAL lcPartyName
LOCAL lcIpAddress
LOCAL lcTypeId
LOCAL lcValue
LOCAL lcRegisteredId
LOCAL lcRfc822Name
LOCAL lcUniformResourceIdentifier
LOCAL lcAccessMethodType
LOCAL lcCustomObjectIdentifier
LOCAL lcArn
LOCAL lnCRLSign
LOCAL lnDataEncipherment
LOCAL lnDecipherOnly
LOCAL lnDigitalSignature
LOCAL lnEncipherOnly
LOCAL lnKeyAgreement
LOCAL lnKeyCertSign
LOCAL lnKeyEncipherment
LOCAL lnNonRepudiation
LOCAL lcKeyAlgorithm
LOCAL lcSigningAlgorithm
LOCAL lcCommonName
LOCAL lcCountry
LOCAL lcDistinguishedNameQualifier
LOCAL lcGenerationQualifier
LOCAL lcGivenName
LOCAL lcInitials
LOCAL lcLocality
LOCAL lcOrganization
LOCAL lcOrganizationalUnit
LOCAL lcPseudonym
LOCAL lcSerialNumber
LOCAL lcState
LOCAL lcSurname
LOCAL lcTitle
LOCAL lnCreatedAt
LOCAL lcFailureReason
LOCAL lcKeyStorageSecurityStandard
LOCAL lnLastStateChangeAt
LOCAL lnNotAfter
LOCAL lnNotBefore
LOCAL lcOwnerAccount
LOCAL lnRestorableUntil
LOCAL lcCustomCname
LOCAL lnEnabled
LOCAL lnExpirationInDays
LOCAL lcS3BucketName
LOCAL lcS3ObjectAcl
LOCAL lnOcspConfigurationEnabled
LOCAL lcOcspCustomCname
LOCAL lcSerial
LOCAL lcStatus
LOCAL lcV_Type
LOCAL i
LOCAL lnCount_i

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

loRest = CreateObject('Chilkat_9_5_0.Rest')

loAuthAws = CreateObject('Chilkat_9_5_0.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.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.)
loAuthAws.Region = "us-west-2"
loAuthAws.ServiceName = "acm-pca"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)

* URL: https://acm-pca.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("acm-pca.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loAuthAws
    CANCEL
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

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("CertificateAuthorityArn","string")

* The JSON request body created by the above code:

* {
*   "CertificateAuthorityArn": "string"
* }

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

loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loJson
    RELEASE loSbRequestBody
    RELEASE loSbResponseBody
    CANCEL
ENDIF

lnRespStatusCode = loRest.ResponseStatusCode
? "response status code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 200) THEN
    ? "Response Header:"
    ? loRest.ResponseHeader
    ? "Response Body:"
    ? loSbResponseBody.GetAsString()
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loJson
    RELEASE loSbRequestBody
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)

* 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

lcArn = loJResp.StringOf("CertificateAuthority.Arn")
lnCRLSign = loJResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.CRLSign")
lnDataEncipherment = loJResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DataEncipherment")
lnDecipherOnly = loJResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DecipherOnly")
lnDigitalSignature = loJResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DigitalSignature")
lnEncipherOnly = loJResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.EncipherOnly")
lnKeyAgreement = loJResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyAgreement")
lnKeyCertSign = loJResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyCertSign")
lnKeyEncipherment = loJResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyEncipherment")
lnNonRepudiation = loJResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.NonRepudiation")
lcKeyAlgorithm = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.KeyAlgorithm")
lcSigningAlgorithm = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.SigningAlgorithm")
lcCommonName = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.CommonName")
lcCountry = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Country")
lcDistinguishedNameQualifier = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.DistinguishedNameQualifier")
lcGenerationQualifier = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.GenerationQualifier")
lcGivenName = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.GivenName")
lcInitials = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Initials")
lcLocality = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Locality")
lcOrganization = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Organization")
lcOrganizationalUnit = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.OrganizationalUnit")
lcPseudonym = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Pseudonym")
lcSerialNumber = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.SerialNumber")
lcState = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.State")
lcSurname = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Surname")
lcTitle = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Title")
lnCreatedAt = loJResp.IntOf("CertificateAuthority.CreatedAt")
lcFailureReason = loJResp.StringOf("CertificateAuthority.FailureReason")
lcKeyStorageSecurityStandard = loJResp.StringOf("CertificateAuthority.KeyStorageSecurityStandard")
lnLastStateChangeAt = loJResp.IntOf("CertificateAuthority.LastStateChangeAt")
lnNotAfter = loJResp.IntOf("CertificateAuthority.NotAfter")
lnNotBefore = loJResp.IntOf("CertificateAuthority.NotBefore")
lcOwnerAccount = loJResp.StringOf("CertificateAuthority.OwnerAccount")
lnRestorableUntil = loJResp.IntOf("CertificateAuthority.RestorableUntil")
lcCustomCname = loJResp.StringOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.CustomCname")
lnEnabled = loJResp.IntOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.Enabled")
lnExpirationInDays = loJResp.IntOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.ExpirationInDays")
lcS3BucketName = loJResp.StringOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.S3BucketName")
lcS3ObjectAcl = loJResp.StringOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.S3ObjectAcl")
lnOcspConfigurationEnabled = loJResp.IntOf("CertificateAuthority.RevocationConfiguration.OcspConfiguration.Enabled")
lcOcspCustomCname = loJResp.StringOf("CertificateAuthority.RevocationConfiguration.OcspConfiguration.OcspCustomCname")
lcSerial = loJResp.StringOf("CertificateAuthority.Serial")
lcStatus = loJResp.StringOf("CertificateAuthority.Status")
lcV_Type = loJResp.StringOf("CertificateAuthority.Type")
i = 0
lnCount_i = loJResp.SizeOfArray("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcDirectoryNameCommonName = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.CommonName")
    lcDirectoryNameCountry = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Country")
    lcDirectoryNameDistinguishedNameQualifier = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.DistinguishedNameQualifier")
    lcDirectoryNameGenerationQualifier = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.GenerationQualifier")
    lcDirectoryNameGivenName = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.GivenName")
    lcDirectoryNameInitials = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Initials")
    lcDirectoryNameLocality = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Locality")
    lcDirectoryNameOrganization = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Organization")
    lcDirectoryNameOrganizationalUnit = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.OrganizationalUnit")
    lcDirectoryNamePseudonym = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Pseudonym")
    lcDirectoryNameSerialNumber = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.SerialNumber")
    lcDirectoryNameState = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.State")
    lcDirectoryNameSurname = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Surname")
    lcDirectoryNameTitle = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Title")
    lcDnsName = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DnsName")
    lcNameAssigner = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.EdiPartyName.NameAssigner")
    lcPartyName = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.EdiPartyName.PartyName")
    lcIpAddress = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.IpAddress")
    lcTypeId = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.OtherName.TypeId")
    lcValue = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.OtherName.Value")
    lcRegisteredId = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.RegisteredId")
    lcRfc822Name = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.Rfc822Name")
    lcUniformResourceIdentifier = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.UniformResourceIdentifier")
    lcAccessMethodType = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessMethod.AccessMethodType")
    lcCustomObjectIdentifier = loJResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessMethod.CustomObjectIdentifier")
    i = i + 1
ENDDO

* 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"
*   }
* }

RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp