Chilkat Online Tools

DescribeCertificateAuthority Node.js Example

AWS Private CA

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node17-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node17-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node17-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node17-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node17-linux64');
    }
} else if (os.platform() == 'darwin') {
    var chilkat = require('@chilkat/ck-node17-macosx');
}

function chilkatExample() {

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

    var rest = new chilkat.Rest();
    var success;

    var authAws = new chilkat.AuthAws();
    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
    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) {
        console.log("ConnectFailReason: " + rest.ConnectFailReason);
        console.log(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

    var json = new chilkat.JsonObject();
    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");

    var sbRequestBody = new chilkat.StringBuilder();
    json.EmitSb(sbRequestBody);
    var sbResponseBody = new chilkat.StringBuilder();
    success = rest.FullRequestSb("POST","/",sbRequestBody,sbResponseBody);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    var respStatusCode = rest.ResponseStatusCode;
    console.log("response status code = " + respStatusCode);
    if (respStatusCode !== 200) {
        console.log("Response Header:");
        console.log(rest.ResponseHeader);
        console.log("Response Body:");
        console.log(sbResponseBody.GetAsString());
        return;
    }

    var jResp = new chilkat.JsonObject();
    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

    var DirectoryNameCommonName;
    var DirectoryNameCountry;
    var DirectoryNameDistinguishedNameQualifier;
    var DirectoryNameGenerationQualifier;
    var DirectoryNameGivenName;
    var DirectoryNameInitials;
    var DirectoryNameLocality;
    var DirectoryNameOrganization;
    var DirectoryNameOrganizationalUnit;
    var DirectoryNamePseudonym;
    var DirectoryNameSerialNumber;
    var DirectoryNameState;
    var DirectoryNameSurname;
    var DirectoryNameTitle;
    var DnsName;
    var NameAssigner;
    var PartyName;
    var IpAddress;
    var TypeId;
    var Value;
    var RegisteredId;
    var Rfc822Name;
    var UniformResourceIdentifier;
    var AccessMethodType;
    var CustomObjectIdentifier;

    var Arn = jResp.StringOf("CertificateAuthority.Arn");
    var CRLSign = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.CRLSign");
    var DataEncipherment = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DataEncipherment");
    var DecipherOnly = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DecipherOnly");
    var DigitalSignature = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.DigitalSignature");
    var EncipherOnly = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.EncipherOnly");
    var KeyAgreement = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyAgreement");
    var KeyCertSign = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyCertSign");
    var KeyEncipherment = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.KeyEncipherment");
    var NonRepudiation = jResp.IntOf("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.KeyUsage.NonRepudiation");
    var KeyAlgorithm = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.KeyAlgorithm");
    var SigningAlgorithm = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.SigningAlgorithm");
    var CommonName = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.CommonName");
    var Country = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Country");
    var DistinguishedNameQualifier = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.DistinguishedNameQualifier");
    var GenerationQualifier = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.GenerationQualifier");
    var GivenName = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.GivenName");
    var Initials = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Initials");
    var Locality = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Locality");
    var Organization = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Organization");
    var OrganizationalUnit = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.OrganizationalUnit");
    var Pseudonym = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Pseudonym");
    var SerialNumber = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.SerialNumber");
    var State = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.State");
    var Surname = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Surname");
    var Title = jResp.StringOf("CertificateAuthority.CertificateAuthorityConfiguration.Subject.Title");
    var CreatedAt = jResp.IntOf("CertificateAuthority.CreatedAt");
    var FailureReason = jResp.StringOf("CertificateAuthority.FailureReason");
    var KeyStorageSecurityStandard = jResp.StringOf("CertificateAuthority.KeyStorageSecurityStandard");
    var LastStateChangeAt = jResp.IntOf("CertificateAuthority.LastStateChangeAt");
    var NotAfter = jResp.IntOf("CertificateAuthority.NotAfter");
    var NotBefore = jResp.IntOf("CertificateAuthority.NotBefore");
    var OwnerAccount = jResp.StringOf("CertificateAuthority.OwnerAccount");
    var RestorableUntil = jResp.IntOf("CertificateAuthority.RestorableUntil");
    var CustomCname = jResp.StringOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.CustomCname");
    var Enabled = jResp.IntOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.Enabled");
    var ExpirationInDays = jResp.IntOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.ExpirationInDays");
    var S3BucketName = jResp.StringOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.S3BucketName");
    var S3ObjectAcl = jResp.StringOf("CertificateAuthority.RevocationConfiguration.CrlConfiguration.S3ObjectAcl");
    var OcspConfigurationEnabled = jResp.IntOf("CertificateAuthority.RevocationConfiguration.OcspConfiguration.Enabled");
    var OcspCustomCname = jResp.StringOf("CertificateAuthority.RevocationConfiguration.OcspConfiguration.OcspCustomCname");
    var Serial = jResp.StringOf("CertificateAuthority.Serial");
    var Status = jResp.StringOf("CertificateAuthority.Status");
    var v_Type = jResp.StringOf("CertificateAuthority.Type");
    var i = 0;
    var count_i = jResp.SizeOfArray("CertificateAuthority.CertificateAuthorityConfiguration.CsrExtensions.SubjectInformationAccess");
    while (i < count_i) {
        jResp.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"
    //   }
    // }

}

chilkatExample();