Sample code for 30+ languages & platforms
Objective-C Requires Chilkat v11.6.0+

AWS KMS: Import a PFX Key into an Existing External Signing Key

See more AWS KMS Examples

Uses the current AWS KMS API. Configure the region and keep credentials in private qa_data/aws/kms.json, with nonempty string fields access_key and secret_key. The examples do not obtain or refresh credentials. Keep diagnostics private; they may contain credentials or sensitive key data. Create the output directory before running file-writing examples.

Uses the AWS JSON 1.1 protocol with TrentService targets, service kms, HTTPS certificate verification, and Signature Version 4. When using temporary credentials, also provide a nonempty session_token; this Rest example includes it in the signed query on each request. Never log that URL. The endpoint shown is for the commercial AWS partition; use the appropriate endpoint for other partitions. Failures stop the sample; production retry policies should use bounded backoff with jitter and reconcile uncertain writes.

Loads the certificate's private key from qa_data/pfx/myCertAndKey.pfx using string field pfx_password from the private configuration. Supports RSA 2048/3072/4096 and NIST P-256/P-384/P-521 in this sample. Keep a protected backup of the original material: KMS cannot export it. RSA material must satisfy AWS's current key-material requirements. Tags are visible metadata; do not put passwords or sensitive certificate identity data in them.

First create a compatible Origin=EXTERNAL, KeyUsage=SIGN_VERIFY KMS key with the correct KeySpec and provide its ID or ARN in key_id. This example requires PendingImport, checks metadata, pins the resolved ARN, obtains a fresh wrapping key/token pair, and imports PKCS#8 using RSA_AES_KEY_WRAP_SHA_256 and RSA_4096. It creates no new KMS key and makes no automatic retries. Required actions: kms:DescribeKey, kms:GetParametersForImport, and kms:ImportKeyMaterial.

Uses RFC 5649 AES key wrap with padding and RSA-OAEP with SHA-256 for both OAEP and MGF1. Hybrid RSA/AES wrapping is not supported in China Regions. The token and wrapping key must come from the same response for the same key and be used before ParametersValidTo (normally 24 hours). The sample chooses KEY_MATERIAL_DOES_NOT_EXPIRE explicitly; applications needing expiration must use KEY_MATERIAL_EXPIRES and a valid future ValidTo. Acceptance is not an immediate Enabled-state guarantee. Reimports and imported symmetric-key rotation require separate handling; this sample is for an initial asymmetric import.

AWS ImportKeyMaterial reference

Chilkat Objective-C Downloads

Objective-C
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
#import <CkoAuthAws.h>
#import <CkoRest.h>
#import <CkoSocket.h>
#import <CkoCert.h>
#import <CkoPrivateKey.h>
#import <CkoPublicKey.h>
#import <CkoDateTime.h>
#import <CkoPrng.h>
#import <CkoCrypt2.h>
#import <CkoBinData.h>
#import <CkoRsa.h>

BOOL success = NO;

CkoStringBuilder *stringCompare = [[CkoStringBuilder alloc] init];
//  Assumes Chilkat is unlocked. See Global Unlock Sample.
//  Keep this credentials file outside public web content and source control.
CkoJsonObject *credentials = [[CkoJsonObject alloc] init];
credentials.Strict = YES;
success = [credentials LoadFile: @"qa_data/aws/kms.json"];
if (success != YES) {
    NSLog(@"%@",@"Could not load private KMS configuration.");
    return;
}

[stringCompare SetString: [credentials StringOf: @"access_key"]];
BOOL stringMatch1 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
if (([[credentials JsonTypeOf: @"access_key"] intValue] != 1) || (stringMatch1 == YES)) {
    NSLog(@"%@",@"Missing or invalid access_key.");
    return;
}

[stringCompare SetString: [credentials StringOf: @"secret_key"]];
BOOL stringMatch2 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
if (([[credentials JsonTypeOf: @"secret_key"] intValue] != 1) || (stringMatch2 == YES)) {
    NSLog(@"%@",@"Missing or invalid secret_key.");
    return;
}

NSString *region = @"us-west-2";
CkoStringBuilder *endpoint = [[CkoStringBuilder alloc] init];
[endpoint Append: @"kms."];
[endpoint Append: region];
[endpoint Append: @".amazonaws.com"];
CkoAuthAws *aws = [[CkoAuthAws alloc] init];
aws.AccessKey = [credentials StringOf: @"access_key"];
aws.SecretKey = [credentials StringOf: @"secret_key"];
aws.Region = region;
aws.ServiceName = @"kms";
aws.SignatureVersion = [NSNumber numberWithInt:4];
CkoRest *rest = [[CkoRest alloc] init];
rest.ConnectTimeoutMs = [NSNumber numberWithInt:20000];
rest.IdleTimeoutMs = [NSNumber numberWithInt:60000];
rest.VerboseLogging = NO;
success = [rest SetAuthAws: aws];
if (success != YES) {
    NSLog(@"%@",@"Could not configure AWS signing.");
    return;
}

if ([credentials HasMember: @"session_token"] == YES) {
    [stringCompare SetString: [credentials StringOf: @"session_token"]];
    BOOL stringMatch3 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
    if (([[credentials JsonTypeOf: @"session_token"] intValue] != 1) || (stringMatch3 == YES)) {
        NSLog(@"%@",@"Missing or invalid session_token.");
        return;
    }

}

CkoSocket *connection = [[CkoSocket alloc] init];
connection.RequireSslCertVerify = YES;
connection.MaxReadIdleMs = [NSNumber numberWithInt:60000];
connection.MaxSendIdleMs = [NSNumber numberWithInt:60000];
success = [connection Connect: [endpoint GetAsString] port: [NSNumber numberWithInt: 443] ssl: YES maxWaitMs: [NSNumber numberWithInt: 20000]];
if (success != YES) {
    NSLog(@"%@",@"TLS connection failed; inspect diagnostics privately.");
    return;
}

success = [rest UseConnection: connection autoReconnect: YES];
if (success != YES) {
    NSLog(@"%@",@"Could not attach TLS connection.");
    return;
}

//  Keep connection alive while Rest uses it.
CkoJsonObject *body = [[CkoJsonObject alloc] init];
CkoJsonObject *result = [[CkoJsonObject alloc] init];
result.Strict = YES;
NSString *responseJson = 0;
//  pfx_password is a string; an empty string is allowed for an unprotected PFX.
if ([[credentials JsonTypeOf: @"pfx_password"] intValue] != 1) {
    NSLog(@"%@",@"Missing or invalid pfx_password.");
    return;
}

CkoCert *cert = [[CkoCert alloc] init];
success = [cert LoadPfxFile: @"qa_data/pfx/myCertAndKey.pfx" password: [credentials StringOf: @"pfx_password"]];
if (success != YES) {
    NSLog(@"%@",@"Could not load PFX; inspect diagnostics privately.");
    return;
}

CkoPrivateKey *privKey = [[CkoPrivateKey alloc] init];
success = [cert GetPrivateKey: privKey];
if (success != YES) {
    NSLog(@"%@",@"PFX does not contain a usable private key.");
    return;
}

//  Only inspect the PUBLIC JWK to identify a supported key type and curve.
CkoPublicKey *sourcePublic = [[CkoPublicKey alloc] init];
success = [privKey ToPublicKey: sourcePublic];
if (success != YES) {
    NSLog(@"%@",@"Could not get the public key.");
    return;
}

NSString *publicJwk = [sourcePublic GetJwk];
if (sourcePublic.LastMethodSuccess != YES) {
    NSLog(@"%@",@"Could not inspect public key type.");
    return;
}

CkoJsonObject *keyInfo = [[CkoJsonObject alloc] init];
keyInfo.Strict = YES;
success = [keyInfo Load: publicJwk];
if (success != YES) {
    NSLog(@"%@",@"Could not parse public key description.");
    return;
}

NSString *keySpec = @"";
[stringCompare SetString: [keyInfo StringOf: @"kty"]];
BOOL stringMatch4 = [stringCompare ContentsEqual: @"RSA" caseSensitive: YES];
if (stringMatch4 == YES) {
    if ([privKey.BitLength intValue] == 2048) {
        keySpec = @"RSA_2048";
    }

    if ([privKey.BitLength intValue] == 3072) {
        keySpec = @"RSA_3072";
    }

    if ([privKey.BitLength intValue] == 4096) {
        keySpec = @"RSA_4096";
    }

}

[stringCompare SetString: [keyInfo StringOf: @"kty"]];
BOOL stringMatch5 = [stringCompare ContentsEqual: @"EC" caseSensitive: YES];
if (stringMatch5 == YES) {
    [stringCompare SetString: [keyInfo StringOf: @"crv"]];
    BOOL stringMatch6 = [stringCompare ContentsEqual: @"P-256" caseSensitive: YES];
    if (stringMatch6 == YES) {
        keySpec = @"ECC_NIST_P256";
    }

    [stringCompare SetString: [keyInfo StringOf: @"crv"]];
    BOOL stringMatch7 = [stringCompare ContentsEqual: @"P-384" caseSensitive: YES];
    if (stringMatch7 == YES) {
        keySpec = @"ECC_NIST_P384";
    }

    [stringCompare SetString: [keyInfo StringOf: @"crv"]];
    BOOL stringMatch8 = [stringCompare ContentsEqual: @"P-521" caseSensitive: YES];
    if (stringMatch8 == YES) {
        keySpec = @"ECC_NIST_P521";
    }

}

[stringCompare SetString: keySpec];
BOOL stringMatch9 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
if (stringMatch9 == YES) {
    NSLog(@"%@",@"Use RSA 2048/3072/4096 or a NIST P-256/P-384/P-521 EC private key.");
    return;
}

[stringCompare SetString: [credentials StringOf: @"key_id"]];
BOOL stringMatch10 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
if (([[credentials JsonTypeOf: @"key_id"] intValue] != 1) || (stringMatch10 == YES)) {
    NSLog(@"%@",@"Missing or invalid key_id.");
    return;
}

NSString *keyId = [credentials StringOf: @"key_id"];
success = [body UpdateString: @"KeyId" value: keyId];
if (success != YES) {
    NSLog(@"%@",@"Could not set KeyId.");
    return;
}

success = [rest ClearAllQueryParams];
if (success != YES) {
    NSLog(@"%@",@"Could not clear previous query parameters.");
    return;
}

//  Keep the JSON operation body separate from authentication parameters.
//  Include STS credentials in the signed query; never log the request URL.
if ([credentials HasMember: @"session_token"] == YES) {
    success = [rest AddQueryParam: @"X-Amz-Security-Token" value: [credentials StringOf: @"session_token"]];
    if (success != YES) {
        NSLog(@"%@",@"Could not set session token.");
        return;
    }

}

success = [rest AddHeader: @"X-Amz-Target" value: @"TrentService.DescribeKey"];
if (success != YES) {
    NSLog(@"%@",@"Could not set operation.");
    return;
}

success = [rest AddHeader: @"Content-Type" value: @"application/x-amz-json-1.1"];
if (success != YES) {
    NSLog(@"%@",@"Could not set content type.");
    return;
}

responseJson = [rest FullRequestString: @"POST" uriPath: @"/" bodyText: [body Emit]];
if (rest.LastMethodSuccess != YES) {
    NSLog(@"%@",@"KMS request did not complete; inspect diagnostics privately. Reconcile any write before retrying.");
    return;
}

if ([rest.ResponseStatusCode intValue] != 200) {
    NSLog(@"%@%d",@"KMS HTTP status: ",[rest.ResponseStatusCode intValue]);
    success = [result Load: responseJson];
    if (success == YES) {
        if ([[result JsonTypeOf: @"__type"] intValue] == 1) {
            NSLog(@"%@%@",@"AWS error code: ",[result StringOf: @"__type"]);
        }

    }

    NSLog(@"%@%@",@"AWS request ID: ",[rest ResponseHdrByName: @"x-amzn-RequestId"]);
    //  Do not print full bodies, headers, credentials, key material, or tokens.
    return;
}

success = [result Load: responseJson];
if (success != YES) {
    NSLog(@"%@",@"Expected a well-formed JSON response.");
    return;
}

[stringCompare SetString: [result StringOf: @"KeyMetadata.KeyId"]];
BOOL stringMatch11 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
if (([[result JsonTypeOf: @"KeyMetadata.KeyId"] intValue] != 1) || (stringMatch11 == YES)) {
    NSLog(@"%@",@"Missing or invalid KeyMetadata.KeyId.");
    return;
}

[stringCompare SetString: [result StringOf: @"KeyMetadata.Arn"]];
BOOL stringMatch12 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
if (([[result JsonTypeOf: @"KeyMetadata.Arn"] intValue] != 1) || (stringMatch12 == YES)) {
    NSLog(@"%@",@"Missing or invalid KeyMetadata.Arn.");
    return;
}

[stringCompare SetString: [result StringOf: @"KeyMetadata.Origin"]];
BOOL stringMatch13 = [stringCompare ContentsEqual: @"EXTERNAL" caseSensitive: YES];
if (stringMatch13 != YES) {
    NSLog(@"%@",@"Destination must have EXTERNAL origin.");
    return;
}

[stringCompare SetString: [result StringOf: @"KeyMetadata.KeyState"]];
BOOL stringMatch14 = [stringCompare ContentsEqual: @"PendingImport" caseSensitive: YES];
if (stringMatch14 != YES) {
    NSLog(@"%@",@"This initial-import sample requires PendingImport; it does not replace existing material.");
    return;
}

[stringCompare SetString: [result StringOf: @"KeyMetadata.KeyUsage"]];
BOOL stringMatch15 = [stringCompare ContentsEqual: @"SIGN_VERIFY" caseSensitive: YES];
if (stringMatch15 != YES) {
    NSLog(@"%@",@"Destination must have SIGN_VERIFY usage.");
    return;
}

[stringCompare SetString: [result StringOf: @"KeyMetadata.KeySpec"]];
BOOL stringMatch16 = [stringCompare ContentsEqual: keySpec caseSensitive: YES];
if (stringMatch16 != YES) {
    NSLog(@"%@",@"PFX private key does not match the destination KeySpec.");
    return;
}

//  Pin subsequent requests to the resolved ARN, not a mutable alias.
keyId = [result StringOf: @"KeyMetadata.Arn"];
[body Clear];
success = [body UpdateString: @"KeyId" value: keyId];
if (success != YES) {
    NSLog(@"%@",@"Could not set KeyId.");
    return;
}

success = [body UpdateString: @"WrappingAlgorithm" value: @"RSA_AES_KEY_WRAP_SHA_256"];
if (success != YES) {
    NSLog(@"%@",@"Could not set WrappingAlgorithm.");
    return;
}

success = [body UpdateString: @"WrappingKeySpec" value: @"RSA_4096"];
if (success != YES) {
    NSLog(@"%@",@"Could not set WrappingKeySpec.");
    return;
}

success = [rest ClearAllQueryParams];
if (success != YES) {
    NSLog(@"%@",@"Could not clear previous query parameters.");
    return;
}

//  Keep the JSON operation body separate from authentication parameters.
//  Include STS credentials in the signed query; never log the request URL.
if ([credentials HasMember: @"session_token"] == YES) {
    success = [rest AddQueryParam: @"X-Amz-Security-Token" value: [credentials StringOf: @"session_token"]];
    if (success != YES) {
        NSLog(@"%@",@"Could not set session token.");
        return;
    }

}

success = [rest AddHeader: @"X-Amz-Target" value: @"TrentService.GetParametersForImport"];
if (success != YES) {
    NSLog(@"%@",@"Could not set operation.");
    return;
}

success = [rest AddHeader: @"Content-Type" value: @"application/x-amz-json-1.1"];
if (success != YES) {
    NSLog(@"%@",@"Could not set content type.");
    return;
}

responseJson = [rest FullRequestString: @"POST" uriPath: @"/" bodyText: [body Emit]];
if (rest.LastMethodSuccess != YES) {
    NSLog(@"%@",@"KMS request did not complete; inspect diagnostics privately. Reconcile any write before retrying.");
    return;
}

if ([rest.ResponseStatusCode intValue] != 200) {
    NSLog(@"%@%d",@"KMS HTTP status: ",[rest.ResponseStatusCode intValue]);
    success = [result Load: responseJson];
    if (success == YES) {
        if ([[result JsonTypeOf: @"__type"] intValue] == 1) {
            NSLog(@"%@%@",@"AWS error code: ",[result StringOf: @"__type"]);
        }

    }

    NSLog(@"%@%@",@"AWS request ID: ",[rest ResponseHdrByName: @"x-amzn-RequestId"]);
    //  Do not print full bodies, headers, credentials, key material, or tokens.
    return;
}

success = [result Load: responseJson];
if (success != YES) {
    NSLog(@"%@",@"Expected a well-formed JSON response.");
    return;
}

[stringCompare SetString: [result StringOf: @"KeyId"]];
BOOL stringMatch17 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
if (([[result JsonTypeOf: @"KeyId"] intValue] != 1) || (stringMatch17 == YES)) {
    NSLog(@"%@",@"Missing or invalid KeyId.");
    return;
}

[stringCompare SetString: [result StringOf: @"KeyId"]];
BOOL stringMatch18 = [stringCompare ContentsEqual: keyId caseSensitive: YES];
if (stringMatch18 != YES) {
    NSLog(@"%@",@"Import parameters belong to another key.");
    return;
}

[stringCompare SetString: [result StringOf: @"ImportToken"]];
BOOL stringMatch19 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
if (([[result JsonTypeOf: @"ImportToken"] intValue] != 1) || (stringMatch19 == YES)) {
    NSLog(@"%@",@"Missing or invalid ImportToken.");
    return;
}

[stringCompare SetString: [result StringOf: @"PublicKey"]];
BOOL stringMatch20 = [stringCompare ContentsEqual: @"" caseSensitive: YES];
if (([[result JsonTypeOf: @"PublicKey"] intValue] != 1) || (stringMatch20 == YES)) {
    NSLog(@"%@",@"Missing or invalid PublicKey.");
    return;
}

if ([[result JsonTypeOf: @"ParametersValidTo"] intValue] != 2) {
    NSLog(@"%@",@"Missing import-parameter expiration.");
    return;
}

CkoDateTime *now = [[CkoDateTime alloc] init];
CkoDateTime *expires = [[CkoDateTime alloc] init];
success = [now SetFromCurrentSystemTime];
if (success != YES) {
    NSLog(@"%@",@"Could not read current time.");
    return;
}

success = [result DateOf: @"ParametersValidTo" dateTime: expires];
if (success != YES) {
    NSLog(@"%@",@"Invalid import-parameter expiration.");
    return;
}

if ([[expires DiffSeconds: now] intValue] <= 0) {
    NSLog(@"%@",@"Import parameters have expired; obtain a fresh token and wrapping key together.");
    return;
}

NSString *importToken = [result StringOf: @"ImportToken"];
CkoPublicKey *wrappingKey = [[CkoPublicKey alloc] init];
success = [wrappingKey LoadBase64: [result StringOf: @"PublicKey"]];
if (success != YES) {
    NSLog(@"%@",@"Could not load the RSA wrapping key.");
    return;
}

if ([wrappingKey.KeySize intValue] != 4096) {
    NSLog(@"%@",@"Expected the requested 4096-bit RSA wrapping key.");
    return;
}

//  Export PKCS#8 DER in memory only; never print or write unencrypted key material.
NSString *pkcs8Base64 = [privKey GetPkcs8ENC: @"base64"];
if (privKey.LastMethodSuccess != YES) {
    NSLog(@"%@",@"Could not encode the private key as PKCS#8.");
    return;
}

CkoPrng *prng = [[CkoPrng alloc] init];
//  A fresh 32-byte (256-bit) AES key, not a 32-bit key.
NSString *aesKeyBase64 = [prng GenRandom: [NSNumber numberWithInt: 32] encoding: @"base64"];
if (prng.LastMethodSuccess != YES) {
    NSLog(@"%@",@"Could not generate wrapping key.");
    return;
}

CkoCrypt2 *crypt = [[CkoCrypt2 alloc] init];
NSString *wrappedPrivateKey = [crypt AesKeyWrapWithPadding: aesKeyBase64 keyData: pkcs8Base64 encoding: @"base64"];
if (crypt.LastMethodSuccess != YES) {
    NSLog(@"%@",@"AES key wrapping failed.");
    return;
}

CkoBinData *wrappedAesKey = [[CkoBinData alloc] init];
success = [wrappedAesKey AppendEncoded: aesKeyBase64 encoding: @"base64"];
if (success != YES) {
    NSLog(@"%@",@"Could not decode AES key.");
    return;
}

CkoRsa *rsa = [[CkoRsa alloc] init];
success = [rsa UsePublicKey: wrappingKey];
if (success != YES) {
    NSLog(@"%@",@"Could not select the RSA wrapping key.");
    return;
}

rsa.PkcsPadding = NO;
rsa.OaepHash = @"sha256";
rsa.OaepMgfHash = @"sha256";
success = [rsa EncryptBd: wrappedAesKey usePrivateKey: NO];
if (success != YES) {
    NSLog(@"%@",@"RSA-OAEP AES-key wrapping failed.");
    return;
}

//  Wire order is RSA-wrapped AES key FIRST, followed by AES-wrapped PKCS#8.
CkoBinData *encryptedMaterial = [[CkoBinData alloc] init];
success = [encryptedMaterial AppendBd: wrappedAesKey];
if (success != YES) {
    NSLog(@"%@",@"Could not assemble encrypted material.");
    return;
}

success = [encryptedMaterial AppendEncoded: wrappedPrivateKey encoding: @"base64"];
if (success != YES) {
    NSLog(@"%@",@"Could not append wrapped private key.");
    return;
}

[body Clear];
success = [body UpdateString: @"KeyId" value: keyId];
if (success != YES) {
    NSLog(@"%@",@"Could not set KeyId.");
    return;
}

success = [body UpdateString: @"ImportToken" value: importToken];
if (success != YES) {
    NSLog(@"%@",@"Could not set ImportToken.");
    return;
}

success = [body UpdateString: @"EncryptedKeyMaterial" value: [encryptedMaterial GetEncoded: @"base64"]];
if (success != YES) {
    NSLog(@"%@",@"Could not set EncryptedKeyMaterial.");
    return;
}

success = [body UpdateString: @"ExpirationModel" value: @"KEY_MATERIAL_DOES_NOT_EXPIRE"];
if (success != YES) {
    NSLog(@"%@",@"Could not set ExpirationModel.");
    return;
}

success = [rest ClearAllQueryParams];
if (success != YES) {
    NSLog(@"%@",@"Could not clear previous query parameters.");
    return;
}

//  Keep the JSON operation body separate from authentication parameters.
//  Include STS credentials in the signed query; never log the request URL.
if ([credentials HasMember: @"session_token"] == YES) {
    success = [rest AddQueryParam: @"X-Amz-Security-Token" value: [credentials StringOf: @"session_token"]];
    if (success != YES) {
        NSLog(@"%@",@"Could not set session token.");
        return;
    }

}

success = [rest AddHeader: @"X-Amz-Target" value: @"TrentService.ImportKeyMaterial"];
if (success != YES) {
    NSLog(@"%@",@"Could not set operation.");
    return;
}

success = [rest AddHeader: @"Content-Type" value: @"application/x-amz-json-1.1"];
if (success != YES) {
    NSLog(@"%@",@"Could not set content type.");
    return;
}

responseJson = [rest FullRequestString: @"POST" uriPath: @"/" bodyText: [body Emit]];
if (rest.LastMethodSuccess != YES) {
    NSLog(@"%@",@"KMS request did not complete; inspect diagnostics privately. Reconcile any write before retrying.");
    return;
}

if ([rest.ResponseStatusCode intValue] != 200) {
    NSLog(@"%@%d",@"KMS HTTP status: ",[rest.ResponseStatusCode intValue]);
    success = [result Load: responseJson];
    if (success == YES) {
        if ([[result JsonTypeOf: @"__type"] intValue] == 1) {
            NSLog(@"%@%@",@"AWS error code: ",[result StringOf: @"__type"]);
        }

    }

    NSLog(@"%@%@",@"AWS request ID: ",[rest ResponseHdrByName: @"x-amzn-RequestId"]);
    //  Do not print full bodies, headers, credentials, key material, or tokens.
    return;
}

//  HTTP 200 indicates acceptance; response content can be empty.
NSLog(@"%@%@",@"Key material import accepted for: ",keyId);
NSLog(@"%@",@"Use DescribeKey to confirm Enabled before signing; KMS is eventually consistent.");
//  This does not securely erase copies of sensitive strings from managed memory.