Chilkat Online Tools

DescribeCertificateAuthority delphiDll Example

AWS Private CA

var
rest: HCkRest;
success: Boolean;
authAws: HCkAuthAws;
json: HCkJsonObject;
sbRequestBody: HCkStringBuilder;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jResp: HCkJsonObject;
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;
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;
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_UpdateString(json,'CertificateAuthorityArn','string');

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

// {
//   "CertificateAuthorityArn": "string"
// }

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

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

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

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

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