DescribeCertificateAuthority C++ Example
#include <CkRest.h>
#include <CkAuthAws.h>
#include <CkJsonObject.h>
#include <CkStringBuilder.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkRest rest;
bool success;
CkAuthAws authAws;
authAws.put_AccessKey("AWS_ACCESS_KEY");
authAws.put_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.put_Region("us-west-2");
authAws.put_ServiceName("acm-pca");
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
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,true,true);
if (success != true) {
std::cout << "ConnectFailReason: " << rest.get_ConnectFailReason() << "\r\n";
std::cout << rest.lastErrorText() << "\r\n";
return;
}
// 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
CkJsonObject json;
json.UpdateString("CertificateAuthorityArn","string");
// The JSON request body created by the above code:
// {
// "CertificateAuthorityArn": "string"
// }
rest.AddHeader("Content-Type","application/x-amz-json-1.1");
rest.AddHeader("X-Amz-Target","ACMPrivateCA.DescribeCertificateAuthority");
CkStringBuilder sbRequestBody;
json.EmitSb(sbRequestBody);
CkStringBuilder sbResponseBody;
success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody);
if (success != true) {
std::cout << rest.lastErrorText() << "\r\n";
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
std::cout << "response status code = " << respStatusCode << "\r\n";
if (respStatusCode != 200) {
std::cout << "Response Header:" << "\r\n";
std::cout << rest.responseHeader() << "\r\n";
std::cout << "Response Body:" << "\r\n";
std::cout << sbResponseBody.getAsString() << "\r\n";
return;
}
CkJsonObject jResp;
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
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
// See this example explaining how this memory should be used: const char * functions.
const char *DirectoryNameCommonName = 0;
const char *DirectoryNameCountry = 0;
const char *DirectoryNameDistinguishedNameQualifier = 0;
const char *DirectoryNameGenerationQualifier = 0;
const char *DirectoryNameGivenName = 0;
const char *DirectoryNameInitials = 0;
const char *DirectoryNameLocality = 0;
const char *DirectoryNameOrganization = 0;
const char *DirectoryNameOrganizationalUnit = 0;
const char *DirectoryNamePseudonym = 0;
const char *DirectoryNameSerialNumber = 0;
const char *DirectoryNameState = 0;
const char *DirectoryNameSurname = 0;
const char *DirectoryNameTitle = 0;
const char *DnsName = 0;
const char *NameAssigner = 0;
const char *PartyName = 0;
const char *IpAddress = 0;
const char *TypeId = 0;
const char *Value = 0;
const char *RegisteredId = 0;
const char *Rfc822Name = 0;
const char *UniformResourceIdentifier = 0;
const char *AccessMethodType = 0;
const char *CustomObjectIdentifier = 0;
const char *Arn = jResp.stringOf("CertificateAuthority.Arn");
int CRLSign = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.CRLSign");
int DataEncipherment = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DataEncipherment");
int DecipherOnly = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DecipherOnly");
int DigitalSignature = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DigitalSignature");
int EncipherOnly = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.EncipherOnly");
int KeyAgreement = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyAgreement");
int KeyCertSign = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyCertSign");
int KeyEncipherment = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyEncipherment");
int NonRepudiation = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.NonRepudiation");
const char *KeyAlgorithm = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.KeyAlgorithm");
const char *SigningAlgorithm = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.SigningAlgorithm");
const char *CommonName = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.CommonName");
const char *Country = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Country");
const char *DistinguishedNameQualifier = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.DistinguishedNameQualifier");
const char *GenerationQualifier = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.GenerationQualifier");
const char *GivenName = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.GivenName");
const char *Initials = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Initials");
const char *Locality = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Locality");
const char *Organization = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Organization");
const char *OrganizationalUnit = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.OrganizationalUnit");
const char *Pseudonym = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Pseudonym");
const char *SerialNumber = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.SerialNumber");
const char *State = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.State");
const char *Surname = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Surname");
const char *Title = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Title");
int CreatedAt = jResp.IntOf("CertificateAuthority.CreatedAt");
const char *FailureReason = jResp.stringOf("CertificateAuthority.FailureReason");
const char *KeyStorageSecurityStandard = jResp.stringOf("CertificateAuthority.KeyStorageSecurityStandard");
int LastStateChangeAt = jResp.IntOf("CertificateAuthority.LastStateChangeAt");
int NotAfter = jResp.IntOf("CertificateAuthority.NotAfter");
int NotBefore = jResp.IntOf("CertificateAuthority.NotBefore");
const char *OwnerAccount = jResp.stringOf("CertificateAuthority.OwnerAccount");
int RestorableUntil = jResp.IntOf("CertificateAuthority.RestorableUntil");
const char *CustomCname = jResp.stringOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.CustomCname");
int Enabled = jResp.IntOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.Enabled");
int ExpirationInDays = jResp.IntOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.ExpirationInDays");
const char *S3BucketName = jResp.stringOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.S3BucketName");
const char *S3ObjectAcl = jResp.stringOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.S3ObjectAcl");
int OcspConfigurationEnabled = jResp.IntOf("CertificateAuthority.RevocationConfiguration.OcspConfiguration.Enabled");
const char *OcspCustomCname = jResp.stringOf("CertificateAuthority.RevocationConfiguration.OcspConfiguration.OcspCustomCname");
const char *Serial = jResp.stringOf("CertificateAuthority.Serial");
const char *Status = jResp.stringOf("CertificateAuthority.Status");
const char *v_Type = jResp.stringOf("CertificateAuthority.Type");
int i = 0;
int count_i = jResp.SizeOfArray("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess");
while (i < count_i) {
jResp.put_I(i);
DirectoryNameCommonName = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.CommonName");
DirectoryNameCountry = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Country");
DirectoryNameDistinguishedNameQualifier = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.DistinguishedNameQualifier");
DirectoryNameGenerationQualifier = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.GenerationQualifier");
DirectoryNameGivenName = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.GivenName");
DirectoryNameInitials = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Initials");
DirectoryNameLocality = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Locality");
DirectoryNameOrganization = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Organization");
DirectoryNameOrganizationalUnit = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.OrganizationalUnit");
DirectoryNamePseudonym = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Pseudonym");
DirectoryNameSerialNumber = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.SerialNumber");
DirectoryNameState = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.State");
DirectoryNameSurname = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Surname");
DirectoryNameTitle = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Title");
DnsName = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DnsName");
NameAssigner = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.EdiPartyName.NameAssigner");
PartyName = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.EdiPartyName.PartyName");
IpAddress = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.IpAddress");
TypeId = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.OtherName.TypeId");
Value = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.OtherName.Value");
RegisteredId = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.RegisteredId");
Rfc822Name = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.Rfc822Name");
UniformResourceIdentifier = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.UniformResourceIdentifier");
AccessMethodType = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessMethod.AccessMethodType");
CustomObjectIdentifier = jResp.stringOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessMethod.CustomObjectIdentifier");
i = i + 1;
}
// 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"
// }
// }
}