IssueCertificate Foxpro Example
LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcCertificateArn
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loRest = CreateObject('Chilkat_9_5_0.Rest')
loAuthAws = CreateObject('Chilkat_9_5_0.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.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.)
loAuthAws.Region = "us-west-2"
loAuthAws.ServiceName = "acm-pca"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)
* URL: https://acm-pca.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("acm-pca.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
CANCEL
ENDIF
* 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
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("ApiPassthrough.Extensions.CertificatePolicies[0].CertPolicyId","string")
loJson.UpdateString("ApiPassthrough.Extensions.CertificatePolicies[0].PolicyQualifiers[0].PolicyQualifierId","string")
loJson.UpdateString("ApiPassthrough.Extensions.CertificatePolicies[0].PolicyQualifiers[0].Qualifier.CpsUri","string")
loJson.UpdateString("ApiPassthrough.Extensions.ExtendedKeyUsage[0].ExtendedKeyUsageObjectIdentifier","string")
loJson.UpdateString("ApiPassthrough.Extensions.ExtendedKeyUsage[0].ExtendedKeyUsageType","string")
loJson.UpdateInt("ApiPassthrough.Extensions.KeyUsage.CRLSign",123)
loJson.UpdateInt("ApiPassthrough.Extensions.KeyUsage.DataEncipherment",123)
loJson.UpdateInt("ApiPassthrough.Extensions.KeyUsage.DecipherOnly",123)
loJson.UpdateInt("ApiPassthrough.Extensions.KeyUsage.DigitalSignature",123)
loJson.UpdateInt("ApiPassthrough.Extensions.KeyUsage.EncipherOnly",123)
loJson.UpdateInt("ApiPassthrough.Extensions.KeyUsage.KeyAgreement",123)
loJson.UpdateInt("ApiPassthrough.Extensions.KeyUsage.KeyCertSign",123)
loJson.UpdateInt("ApiPassthrough.Extensions.KeyUsage.KeyEncipherment",123)
loJson.UpdateInt("ApiPassthrough.Extensions.KeyUsage.NonRepudiation",123)
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.CommonName","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.Country","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.DistinguishedNameQualifier","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.GenerationQualifier","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.GivenName","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.Initials","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.Locality","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.Organization","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.OrganizationalUnit","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.Pseudonym","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.SerialNumber","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.State","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.Surname","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DirectoryName.Title","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].DnsName","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].EdiPartyName.NameAssigner","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].EdiPartyName.PartyName","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].IpAddress","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].OtherName.TypeId","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].OtherName.Value","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].RegisteredId","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].Rfc822Name","string")
loJson.UpdateString("ApiPassthrough.Extensions.SubjectAlternativeNames[0].UniformResourceIdentifier","string")
loJson.UpdateString("ApiPassthrough.Subject.CommonName","string")
loJson.UpdateString("ApiPassthrough.Subject.Country","string")
loJson.UpdateString("ApiPassthrough.Subject.DistinguishedNameQualifier","string")
loJson.UpdateString("ApiPassthrough.Subject.GenerationQualifier","string")
loJson.UpdateString("ApiPassthrough.Subject.GivenName","string")
loJson.UpdateString("ApiPassthrough.Subject.Initials","string")
loJson.UpdateString("ApiPassthrough.Subject.Locality","string")
loJson.UpdateString("ApiPassthrough.Subject.Organization","string")
loJson.UpdateString("ApiPassthrough.Subject.OrganizationalUnit","string")
loJson.UpdateString("ApiPassthrough.Subject.Pseudonym","string")
loJson.UpdateString("ApiPassthrough.Subject.SerialNumber","string")
loJson.UpdateString("ApiPassthrough.Subject.State","string")
loJson.UpdateString("ApiPassthrough.Subject.Surname","string")
loJson.UpdateString("ApiPassthrough.Subject.Title","string")
loJson.UpdateString("CertificateAuthorityArn","string")
loJson.UpdateInt("Csr",123)
loJson.UpdateString("IdempotencyToken","string")
loJson.UpdateString("SigningAlgorithm","string")
loJson.UpdateString("TemplateArn","string")
loJson.UpdateString("Validity.Type","string")
loJson.UpdateInt("Validity.Value",123)
loJson.UpdateString("ValidityNotBefore.Type","string")
loJson.UpdateInt("ValidityNotBefore.Value",123)
* The JSON request body created by the above code:
* {
* "ApiPassthrough": {
* "Extensions": {
* "CertificatePolicies": [
* {
* "CertPolicyId": "string",
* "PolicyQualifiers": [
* {
* "PolicyQualifierId": "string",
* "Qualifier": {
* "CpsUri": "string"
* }
* }
* ]
* }
* ],
* "ExtendedKeyUsage": [
* {
* "ExtendedKeyUsageObjectIdentifier": "string",
* "ExtendedKeyUsageType": "string"
* }
* ],
* "KeyUsage": {
* "CRLSign": boolean,
* "DataEncipherment": boolean,
* "DecipherOnly": boolean,
* "DigitalSignature": boolean,
* "EncipherOnly": boolean,
* "KeyAgreement": boolean,
* "KeyCertSign": boolean,
* "KeyEncipherment": boolean,
* "NonRepudiation": boolean
* },
* "SubjectAlternativeNames": [
* {
* "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"
* }
* ]
* },
* "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"
* }
* },
* "CertificateAuthorityArn": "string",
* "Csr": blob,
* "IdempotencyToken": "string",
* "SigningAlgorithm": "string",
* "TemplateArn": "string",
* "Validity": {
* "Type": "string",
* "Value": number
* },
* "ValidityNotBefore": {
* "Type": "string",
* "Value": number
* }
* }
loRest.AddHeader("Content-Type","application/x-amz-json-1.1")
loRest.AddHeader("X-Amz-Target","ACMPrivateCA.IssueCertificate")
loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
lnRespStatusCode = loRest.ResponseStatusCode
? "response status code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 200) THEN
? "Response Header:"
? loRest.ResponseHeader
? "Response Body:"
? loSbResponseBody.GetAsString()
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
* 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
lcCertificateArn = loJResp.StringOf("CertificateArn")
* A sample JSON response body parsed by the above code:
* {
* "CertificateArn": "string"
* }
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp