Chilkat Online Tools

ListCertificateAuthorities VB6 Example

AWS Private CA

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

Dim rest As New ChilkatRest
Dim success As Long

Dim authAws As New ChilkatAuthAws
authAws.AccessKey = "AWS_ACCESS_KEY"
authAws.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.)
authAws.Region = "us-west-2"
authAws.ServiceName = "acm-pca"
' SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
success = rest.SetAuthAws(authAws)

' URL: https://acm-pca.us-west-2.amazonaws.com/
' Use the same region as specified above.
success = rest.Connect("acm-pca.us-west-2.amazonaws.com",443,1,1)
If (success <> 1) Then
    Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
    Debug.Print rest.LastErrorText
    Exit Sub
End If

' 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

Dim json As New ChilkatJsonObject
success = json.UpdateInt("MaxResults",123)
success = json.UpdateString("NextToken","string")
success = json.UpdateString("ResourceOwner","string")

' The JSON request body created by the above code:

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

success = rest.AddHeader("Content-Type","application/x-amz-json-1.1")
success = rest.AddHeader("X-Amz-Target","ACMPrivateCA.ListCertificateAuthorities")

Dim sbRequestBody As New ChilkatStringBuilder
success = json.EmitSb(sbRequestBody)
Dim sbResponseBody As New ChilkatStringBuilder
success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody)
If (success <> 1) Then
    Debug.Print rest.LastErrorText
    Exit Sub
End If

Dim respStatusCode As Long
respStatusCode = rest.ResponseStatusCode
Debug.Print "response status code = " & respStatusCode
If (respStatusCode <> 200) Then
    Debug.Print "Response Header:"
    Debug.Print rest.ResponseHeader
    Debug.Print "Response Body:"
    Debug.Print sbResponseBody.GetAsString()
    Exit Sub
End If

Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(sbResponseBody)

' 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

Dim Arn As String
Dim CRLSign As Long
Dim DataEncipherment As Long
Dim DecipherOnly As Long
Dim DigitalSignature As Long
Dim EncipherOnly As Long
Dim KeyAgreement As Long
Dim KeyCertSign As Long
Dim KeyEncipherment As Long
Dim NonRepudiation As Long
Dim KeyAlgorithm As String
Dim SigningAlgorithm As String
Dim CommonName As String
Dim Country As String
Dim DistinguishedNameQualifier As String
Dim GenerationQualifier As String
Dim GivenName As String
Dim Initials As String
Dim Locality As String
Dim Organization As String
Dim OrganizationalUnit As String
Dim Pseudonym As String
Dim SerialNumber As String
Dim State As String
Dim Surname As String
Dim Title As String
Dim CreatedAt As Long
Dim FailureReason As String
Dim KeyStorageSecurityStandard As String
Dim LastStateChangeAt As Long
Dim NotAfter As Long
Dim NotBefore As Long
Dim OwnerAccount As String
Dim RestorableUntil As Long
Dim CustomCname As String
Dim Enabled As Long
Dim ExpirationInDays As Long
Dim S3BucketName As String
Dim S3ObjectAcl As String
Dim OcspConfigurationEnabled As Long
Dim OcspCustomCname As String
Dim Serial As String
Dim Status As String
Dim v_Type As String
Dim j As Long
Dim count_j As Long
Dim DirectoryNameCommonName As String
Dim DirectoryNameCountry As String
Dim DirectoryNameDistinguishedNameQualifier As String
Dim DirectoryNameGenerationQualifier As String
Dim DirectoryNameGivenName As String
Dim DirectoryNameInitials As String
Dim DirectoryNameLocality As String
Dim DirectoryNameOrganization As String
Dim DirectoryNameOrganizationalUnit As String
Dim DirectoryNamePseudonym As String
Dim DirectoryNameSerialNumber As String
Dim DirectoryNameState As String
Dim DirectoryNameSurname As String
Dim DirectoryNameTitle As String
Dim DnsName As String
Dim NameAssigner As String
Dim PartyName As String
Dim IpAddress As String
Dim TypeId As String
Dim Value As String
Dim RegisteredId As String
Dim Rfc822Name As String
Dim UniformResourceIdentifier As String
Dim AccessMethodType As String
Dim CustomObjectIdentifier As String

Dim NextToken As String
NextToken = jResp.StringOf("NextToken")
Dim i As Long
i = 0
Dim count_i As Long
count_i = jResp.SizeOfArray("CertificateAuthorities")
Do While i < count_i
    jResp.I = i
    Arn = jResp.StringOf("CertificateAuthorities[i].Arn")
    CRLSign = jResp.IntOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.CRLSign")
    DataEncipherment = jResp.IntOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DataEncipherment")
    DecipherOnly = jResp.IntOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DecipherOnly")
    DigitalSignature = jResp.IntOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DigitalSignature")
    EncipherOnly = jResp.IntOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.EncipherOnly")
    KeyAgreement = jResp.IntOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyAgreement")
    KeyCertSign = jResp.IntOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyCertSign")
    KeyEncipherment = jResp.IntOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyEncipherment")
    NonRepudiation = jResp.IntOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.NonRepudiation")
    KeyAlgorithm = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.KeyAlgorithm")
    SigningAlgorithm = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.SigningAlgorithm")
    CommonName = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.CommonName")
    Country = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Country")
    DistinguishedNameQualifier = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.DistinguishedNameQualifier")
    GenerationQualifier = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.GenerationQualifier")
    GivenName = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.GivenName")
    Initials = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Initials")
    Locality = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Locality")
    Organization = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Organization")
    OrganizationalUnit = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.OrganizationalUnit")
    Pseudonym = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Pseudonym")
    SerialNumber = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.SerialNumber")
    State = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.State")
    Surname = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Surname")
    Title = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Title")
    CreatedAt = jResp.IntOf("CertificateAuthorities[i].CreatedAt")
    FailureReason = jResp.StringOf("CertificateAuthorities[i].FailureReason")
    KeyStorageSecurityStandard = jResp.StringOf("CertificateAuthorities[i].KeyStorageSecurityStandard")
    LastStateChangeAt = jResp.IntOf("CertificateAuthorities[i].LastStateChangeAt")
    NotAfter = jResp.IntOf("CertificateAuthorities[i].NotAfter")
    NotBefore = jResp.IntOf("CertificateAuthorities[i].NotBefore")
    OwnerAccount = jResp.StringOf("CertificateAuthorities[i].OwnerAccount")
    RestorableUntil = jResp.IntOf("CertificateAuthorities[i].RestorableUntil")
    CustomCname = jResp.StringOf("CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.CustomCname")
    Enabled = jResp.IntOf("CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.Enabled")
    ExpirationInDays = jResp.IntOf("CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.ExpirationInDays")
    S3BucketName = jResp.StringOf("CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.S3BucketName")
    S3ObjectAcl = jResp.StringOf("CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.S3ObjectAcl")
    OcspConfigurationEnabled = jResp.IntOf("CertificateAuthorities[i].RevocationConfiguration.OcspConfiguration.Enabled")
    OcspCustomCname = jResp.StringOf("CertificateAuthorities[i].RevocationConfiguration.OcspConfiguration.OcspCustomCname")
    Serial = jResp.StringOf("CertificateAuthorities[i].Serial")
    Status = jResp.StringOf("CertificateAuthorities[i].Status")
    v_Type = jResp.StringOf("CertificateAuthorities[i].Type")
    j = 0
    count_j = jResp.SizeOfArray("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess")
    Do While j < count_j
        jResp.J = j
        DirectoryNameCommonName = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.CommonName")
        DirectoryNameCountry = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Country")
        DirectoryNameDistinguishedNameQualifier = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.DistinguishedNameQualifier")
        DirectoryNameGenerationQualifier = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.GenerationQualifier")
        DirectoryNameGivenName = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.GivenName")
        DirectoryNameInitials = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Initials")
        DirectoryNameLocality = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Locality")
        DirectoryNameOrganization = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Organization")
        DirectoryNameOrganizationalUnit = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.OrganizationalUnit")
        DirectoryNamePseudonym = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Pseudonym")
        DirectoryNameSerialNumber = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.SerialNumber")
        DirectoryNameState = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.State")
        DirectoryNameSurname = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Surname")
        DirectoryNameTitle = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Title")
        DnsName = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DnsName")
        NameAssigner = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.EdiPartyName.NameAssigner")
        PartyName = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.EdiPartyName.PartyName")
        IpAddress = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.IpAddress")
        TypeId = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.OtherName.TypeId")
        Value = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.OtherName.Value")
        RegisteredId = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.RegisteredId")
        Rfc822Name = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.Rfc822Name")
        UniformResourceIdentifier = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.UniformResourceIdentifier")
        AccessMethodType = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessMethod.AccessMethodType")
        CustomObjectIdentifier = jResp.StringOf("CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessMethod.CustomObjectIdentifier")
        j = j + 1
    Loop
    i = i + 1
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"
' }