DescribeCertificateAuthority unicodeCpp Example
#include <CkRestW.h>
#include <CkAuthAwsW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkRestW rest;
bool success;
CkAuthAwsW authAws;
authAws.put_AccessKey(L"AWS_ACCESS_KEY");
authAws.put_SecretKey(L"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(L"us-west-2");
authAws.put_ServiceName(L"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(L"acm-pca.us-west-2.amazonaws.com",443,true,true);
if (success != true) {
wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
wprintf(L"%s\n",rest.lastErrorText());
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
CkJsonObjectW json;
json.UpdateString(L"CertificateAuthorityArn",L"string");
// The JSON request body created by the above code:
// {
// "CertificateAuthorityArn": "string"
// }
rest.AddHeader(L"Content-Type",L"application/x-amz-json-1.1");
rest.AddHeader(L"X-Amz-Target",L"ACMPrivateCA.DescribeCertificateAuthority");
CkStringBuilderW sbRequestBody;
json.EmitSb(sbRequestBody);
CkStringBuilderW sbResponseBody;
success = rest.FullRequestSb(L"POST",L"/",sbRequestBody,sbResponseBody);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
wprintf(L"response status code = %d\n",respStatusCode);
if (respStatusCode != 200) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",rest.responseHeader());
wprintf(L"Response Body:\n");
wprintf(L"%s\n",sbResponseBody.getAsString());
return;
}
CkJsonObjectW 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 wchar_t *DirectoryNameCommonName = 0;
const wchar_t *DirectoryNameCountry = 0;
const wchar_t *DirectoryNameDistinguishedNameQualifier = 0;
const wchar_t *DirectoryNameGenerationQualifier = 0;
const wchar_t *DirectoryNameGivenName = 0;
const wchar_t *DirectoryNameInitials = 0;
const wchar_t *DirectoryNameLocality = 0;
const wchar_t *DirectoryNameOrganization = 0;
const wchar_t *DirectoryNameOrganizationalUnit = 0;
const wchar_t *DirectoryNamePseudonym = 0;
const wchar_t *DirectoryNameSerialNumber = 0;
const wchar_t *DirectoryNameState = 0;
const wchar_t *DirectoryNameSurname = 0;
const wchar_t *DirectoryNameTitle = 0;
const wchar_t *DnsName = 0;
const wchar_t *NameAssigner = 0;
const wchar_t *PartyName = 0;
const wchar_t *IpAddress = 0;
const wchar_t *TypeId = 0;
const wchar_t *Value = 0;
const wchar_t *RegisteredId = 0;
const wchar_t *Rfc822Name = 0;
const wchar_t *UniformResourceIdentifier = 0;
const wchar_t *AccessMethodType = 0;
const wchar_t *CustomObjectIdentifier = 0;
const wchar_t *Arn = jResp.stringOf(L"CertificateAuthority.Arn");
int CRLSign = jResp.IntOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.CRLSign");
int DataEncipherment = jResp.IntOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DataEncipherment");
int DecipherOnly = jResp.IntOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DecipherOnly");
int DigitalSignature = jResp.IntOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DigitalSignature");
int EncipherOnly = jResp.IntOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.EncipherOnly");
int KeyAgreement = jResp.IntOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyAgreement");
int KeyCertSign = jResp.IntOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyCertSign");
int KeyEncipherment = jResp.IntOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyEncipherment");
int NonRepudiation = jResp.IntOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.NonRepudiation");
const wchar_t *KeyAlgorithm = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.KeyAlgorithm");
const wchar_t *SigningAlgorithm = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.SigningAlgorithm");
const wchar_t *CommonName = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.CommonName");
const wchar_t *Country = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.Country");
const wchar_t *DistinguishedNameQualifier = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.DistinguishedNameQualifier");
const wchar_t *GenerationQualifier = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.GenerationQualifier");
const wchar_t *GivenName = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.GivenName");
const wchar_t *Initials = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.Initials");
const wchar_t *Locality = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.Locality");
const wchar_t *Organization = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.Organization");
const wchar_t *OrganizationalUnit = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.OrganizationalUnit");
const wchar_t *Pseudonym = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.Pseudonym");
const wchar_t *SerialNumber = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.SerialNumber");
const wchar_t *State = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.State");
const wchar_t *Surname = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.Surname");
const wchar_t *Title = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.Subject.Title");
int CreatedAt = jResp.IntOf(L"CertificateAuthority.CreatedAt");
const wchar_t *FailureReason = jResp.stringOf(L"CertificateAuthority.FailureReason");
const wchar_t *KeyStorageSecurityStandard = jResp.stringOf(L"CertificateAuthority.KeyStorageSecurityStandard");
int LastStateChangeAt = jResp.IntOf(L"CertificateAuthority.LastStateChangeAt");
int NotAfter = jResp.IntOf(L"CertificateAuthority.NotAfter");
int NotBefore = jResp.IntOf(L"CertificateAuthority.NotBefore");
const wchar_t *OwnerAccount = jResp.stringOf(L"CertificateAuthority.OwnerAccount");
int RestorableUntil = jResp.IntOf(L"CertificateAuthority.RestorableUntil");
const wchar_t *CustomCname = jResp.stringOf(L"CertificateAuthority.RevocationConfiguration.CrlConfiguration.CustomCname");
int Enabled = jResp.IntOf(L"CertificateAuthority.RevocationConfiguration.CrlConfiguration.Enabled");
int ExpirationInDays = jResp.IntOf(L"CertificateAuthority.RevocationConfiguration.CrlConfiguration.ExpirationInDays");
const wchar_t *S3BucketName = jResp.stringOf(L"CertificateAuthority.RevocationConfiguration.CrlConfiguration.S3BucketName");
const wchar_t *S3ObjectAcl = jResp.stringOf(L"CertificateAuthority.RevocationConfiguration.CrlConfiguration.S3ObjectAcl");
int OcspConfigurationEnabled = jResp.IntOf(L"CertificateAuthority.RevocationConfiguration.OcspConfiguration.Enabled");
const wchar_t *OcspCustomCname = jResp.stringOf(L"CertificateAuthority.RevocationConfiguration.OcspConfiguration.OcspCustomCname");
const wchar_t *Serial = jResp.stringOf(L"CertificateAuthority.Serial");
const wchar_t *Status = jResp.stringOf(L"CertificateAuthority.Status");
const wchar_t *v_Type = jResp.stringOf(L"CertificateAuthority.Type");
int i = 0;
int count_i = jResp.SizeOfArray(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess");
while (i < count_i) {
jResp.put_I(i);
DirectoryNameCommonName = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.CommonName");
DirectoryNameCountry = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Country");
DirectoryNameDistinguishedNameQualifier = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.DistinguishedNameQualifier");
DirectoryNameGenerationQualifier = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.GenerationQualifier");
DirectoryNameGivenName = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.GivenName");
DirectoryNameInitials = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Initials");
DirectoryNameLocality = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Locality");
DirectoryNameOrganization = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Organization");
DirectoryNameOrganizationalUnit = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.OrganizationalUnit");
DirectoryNamePseudonym = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Pseudonym");
DirectoryNameSerialNumber = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.SerialNumber");
DirectoryNameState = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.State");
DirectoryNameSurname = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Surname");
DirectoryNameTitle = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DirectoryName.Title");
DnsName = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.DnsName");
NameAssigner = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.EdiPartyName.NameAssigner");
PartyName = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.EdiPartyName.PartyName");
IpAddress = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.IpAddress");
TypeId = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.OtherName.TypeId");
Value = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.OtherName.Value");
RegisteredId = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.RegisteredId");
Rfc822Name = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.Rfc822Name");
UniformResourceIdentifier = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessLocation.UniformResourceIdentifier");
AccessMethodType = jResp.stringOf(L"CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess[i].AccessMethod.AccessMethodType");
CustomObjectIdentifier = jResp.stringOf(L"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"
// }
// }
}