Chilkat Online Tools

ListCertificateAuthorities delphiDll Example

AWS Private CA

var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
json: HCkJsonObject;
sbRequestBody: HCkStringBuilder;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
Arn: PWideChar;
CRLSign: Integer;
DataEncipherment: Integer;
DecipherOnly: Integer;
DigitalSignature: Integer;
EncipherOnly: Integer;
KeyAgreement: Integer;
KeyCertSign: Integer;
KeyEncipherment: Integer;
NonRepudiation: Integer;
KeyAlgorithm: PWideChar;
SigningAlgorithm: PWideChar;
CommonName: PWideChar;
Country: PWideChar;
DistinguishedNameQualifier: PWideChar;
GenerationQualifier: PWideChar;
GivenName: PWideChar;
Initials: PWideChar;
Locality: PWideChar;
Organization: PWideChar;
OrganizationalUnit: PWideChar;
Pseudonym: PWideChar;
SerialNumber: PWideChar;
State: PWideChar;
Surname: PWideChar;
Title: PWideChar;
CreatedAt: Integer;
FailureReason: PWideChar;
KeyStorageSecurityStandard: PWideChar;
LastStateChangeAt: Integer;
NotAfter: Integer;
NotBefore: Integer;
OwnerAccount: PWideChar;
RestorableUntil: Integer;
CustomCname: PWideChar;
Enabled: Integer;
ExpirationInDays: Integer;
S3BucketName: PWideChar;
S3ObjectAcl: PWideChar;
OcspConfigurationEnabled: Integer;
OcspCustomCname: PWideChar;
Serial: PWideChar;
Status: PWideChar;
v_Type: PWideChar;
j: Integer;
count_j: Integer;
DirectoryNameCommonName: PWideChar;
DirectoryNameCountry: PWideChar;
DirectoryNameDistinguishedNameQualifier: PWideChar;
DirectoryNameGenerationQualifier: PWideChar;
DirectoryNameGivenName: PWideChar;
DirectoryNameInitials: PWideChar;
DirectoryNameLocality: PWideChar;
DirectoryNameOrganization: PWideChar;
DirectoryNameOrganizationalUnit: PWideChar;
DirectoryNamePseudonym: PWideChar;
DirectoryNameSerialNumber: PWideChar;
DirectoryNameState: PWideChar;
DirectoryNameSurname: PWideChar;
DirectoryNameTitle: PWideChar;
DnsName: PWideChar;
NameAssigner: PWideChar;
PartyName: PWideChar;
IpAddress: PWideChar;
TypeId: PWideChar;
Value: PWideChar;
RegisteredId: PWideChar;
Rfc822Name: PWideChar;
UniformResourceIdentifier: PWideChar;
AccessMethodType: PWideChar;
CustomObjectIdentifier: PWideChar;
NextToken: PWideChar;
i: Integer;
count_i: Integer;

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

rest := CkRest_Create();

authAws := CkAuthAws_Create();
CkAuthAws_putAccessKey(authAws,'AWS_ACCESS_KEY');
CkAuthAws_putSecretKey(authAws,'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.)
CkAuthAws_putRegion(authAws,'us-west-2');
CkAuthAws_putServiceName(authAws,'acm-pca');
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
CkRest_SetAuthAws(rest,authAws);

// URL: https://acm-pca.us-west-2.amazonaws.com/
// Use the same region as specified above.
success := CkRest_Connect(rest,'acm-pca.us-west-2.amazonaws.com',443,True,True);
if (success <> True) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  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

json := CkJsonObject_Create();
CkJsonObject_UpdateInt(json,'MaxResults',123);
CkJsonObject_UpdateString(json,'NextToken','string');
CkJsonObject_UpdateString(json,'ResourceOwner','string');

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

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

CkRest_AddHeader(rest,'Content-Type','application/x-amz-json-1.1');
CkRest_AddHeader(rest,'X-Amz-Target','ACMPrivateCA.ListCertificateAuthorities');

sbRequestBody := CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestSb(rest,'POST','/',sbRequestBody,sbResponseBody);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;
respStatusCode := CkRest_getResponseStatusCode(rest);
Memo1.Lines.Add('response status code = ' + IntToStr(respStatusCode));
if (respStatusCode <> 200) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkRest__responseHeader(rest));
    Memo1.Lines.Add('Response Body:');
    Memo1.Lines.Add(CkStringBuilder__getAsString(sbResponseBody));
    Exit;
  end;

jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,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

NextToken := CkJsonObject__stringOf(jResp,'NextToken');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'CertificateAuthorities');
while i < count_i do
  begin
    CkJsonObject_putI(jResp,i);
    Arn := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].Arn');
    CRLSign := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.CRLSign');
    DataEncipherment := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DataEncipherment');
    DecipherOnly := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DecipherOnly');
    DigitalSignature := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DigitalSignature');
    EncipherOnly := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.EncipherOnly');
    KeyAgreement := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyAgreement');
    KeyCertSign := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyCertSign');
    KeyEncipherment := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyEncipherment');
    NonRepudiation := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.NonRepudiation');
    KeyAlgorithm := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.KeyAlgorithm');
    SigningAlgorithm := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.SigningAlgorithm');
    CommonName := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.CommonName');
    Country := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Country');
    DistinguishedNameQualifier := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.DistinguishedNameQualifier');
    GenerationQualifier := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.GenerationQualifier');
    GivenName := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.GivenName');
    Initials := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Initials');
    Locality := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Locality');
    Organization := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Organization');
    OrganizationalUnit := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.OrganizationalUnit');
    Pseudonym := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Pseudonym');
    SerialNumber := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.SerialNumber');
    State := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.State');
    Surname := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Surname');
    Title := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.Subject.Title');
    CreatedAt := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].CreatedAt');
    FailureReason := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].FailureReason');
    KeyStorageSecurityStandard := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].KeyStorageSecurityStandard');
    LastStateChangeAt := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].LastStateChangeAt');
    NotAfter := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].NotAfter');
    NotBefore := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].NotBefore');
    OwnerAccount := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].OwnerAccount');
    RestorableUntil := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].RestorableUntil');
    CustomCname := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.CustomCname');
    Enabled := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.Enabled');
    ExpirationInDays := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.ExpirationInDays');
    S3BucketName := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.S3BucketName');
    S3ObjectAcl := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].RevocationConfiguration.CrlConfiguration.S3ObjectAcl');
    OcspConfigurationEnabled := CkJsonObject_IntOf(jResp,'CertificateAuthorities[i].RevocationConfiguration.OcspConfiguration.Enabled');
    OcspCustomCname := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].RevocationConfiguration.OcspConfiguration.OcspCustomCname');
    Serial := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].Serial');
    Status := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].Status');
    v_Type := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].Type');
    j := 0;
    count_j := CkJsonObject_SizeOfArray(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess');
    while j < count_j do
      begin
        CkJsonObject_putJ(jResp,j);
        DirectoryNameCommonName := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.CommonName');
        DirectoryNameCountry := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Country');
        DirectoryNameDistinguishedNameQualifier := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.DistinguishedNameQualifier');
        DirectoryNameGenerationQualifier := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.GenerationQualifier');
        DirectoryNameGivenName := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.GivenName');
        DirectoryNameInitials := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Initials');
        DirectoryNameLocality := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Locality');
        DirectoryNameOrganization := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Organization');
        DirectoryNameOrganizationalUnit := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.OrganizationalUnit');
        DirectoryNamePseudonym := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Pseudonym');
        DirectoryNameSerialNumber := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.SerialNumber');
        DirectoryNameState := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.State');
        DirectoryNameSurname := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Surname');
        DirectoryNameTitle := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DirectoryName.Title');
        DnsName := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.DnsName');
        NameAssigner := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.EdiPartyName.NameAssigner');
        PartyName := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.EdiPartyName.PartyName');
        IpAddress := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.IpAddress');
        TypeId := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.OtherName.TypeId');
        Value := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.OtherName.Value');
        RegisteredId := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.RegisteredId');
        Rfc822Name := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.Rfc822Name');
        UniformResourceIdentifier := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessLocation.UniformResourceIdentifier');
        AccessMethodType := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessMethod.AccessMethodType');
        CustomObjectIdentifier := CkJsonObject__stringOf(jResp,'CertificateAuthorities[i].CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[j].AccessMethod.CustomObjectIdentifier');
        j := j + 1;
      end;

    i := i + 1;
  end;

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

CkRest_Dispose(rest);
CkAuthAws_Dispose(authAws);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);