You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the capabilities of OCI KMS is to import Vault Keys and Key Versions, in case you want to "bring your own key" (BYOK). There is [detailed documentation](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/Content/KeyManagement/Tasks/importingkeys.htm) available on this process but in this example below you will find a brief guide on how to this as it is a tedious and detailed process.
10
10
11
-
This example is for a RSA 2048 Asynchronous key to be imported.
12
11
13
-
# Prerequisites
12
+
# Importing a RSA 2048 Asynchronous key
14
13
15
-
- Make sure to have a up-to-date version of OpenSSL installed that supports the RSA_OAEP_AES_SHA256 wrapping mechanism. OCI CloudShell is currently based on Oracle Linux 7, which does not have the minimum required version of OpenSSL installed.
14
+
This example is for an RSA 2048 Asynchronous Key to be imported in OCI Vault. There are also examples for Synchronous Keys and for importing key versions, see the documentation as mentioned above.
16
15
17
-
- Get a RSA 2048 Key Pair to import and store in the file name **my_keypair.pem**, or generate one via this command:
16
+
## Prerequisites
17
+
18
+
- Make sure to have a up-to-date version of OpenSSL installed that supports the RSA_OAEP_AES_SHA256 wrapping mechanism. OCI CloudShell is currently based on Oracle Linux 7, which does not have the minimum required version of OpenSSL installed. If you create an OCI Compute based on Oracle Linux 9, it should work immediately.
19
+
20
+
- Get a RSA 2048 Key Pair to import and store in the file name ```my_keypair.pem```, or generate one via this command:
18
21
19
22
```openssl genrsa -out my_keypair.pem 2048```
20
23
21
-
#Create the wrapped key material to be imported
24
+
- Create an OCI Vault and copy the Public Wrapping Key. You can find it when creating a new Key in the Vault and enabling the "Import External key" checkbox. For this example store the wrapping key in file called ```pub_wrapping_key.pem```
22
25
23
-
1. Create an OCI Vault and copy the Public Wrapping Key. You can find it when creating a new Key in the Vault and enabling the "Import External key" checkbox. For this example store the wrapping key in file called **pub_wrapping_key.pem**
26
+
### Manually create the wrapped key material to be imported
24
27
25
-
2. Create a temporary AES key:
28
+
1. Create a temporary AES key:
26
29
27
30
```openssl rand -out temp_aes.key 32```
28
31
29
-
3. Wrap the temporary AES Key:
32
+
2. Wrap the temporary AES key with the public wrapping key using RSA-OAEP with SHA-256:
### Use the provided script to generate the wrapped key material to be imported
53
+
54
+
The script is provided in the OCI Documentation [here](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/Content/KeyManagement/Tasks/importing_asymmetric_keys_topic_script_to_import_rsa_key_material_as_a_new_external_key.htm)
55
+
56
+
Just copy the script and place it on an environment where you have the correct version of openssl (see pre-requisites). Then modify the script to have the correct values to point to the required input files. The below example is when you use an OCI Compute with Oracle Linux 9:
57
+
58
+
```
59
+
OPENSSL_PATH="/usr/bin/openssl"
60
+
PRIVATE_KEY="my_keypair.pem"
61
+
WRAPPING_KEY="pub_wrapping_key.pem"
62
+
```
63
+
64
+
After the script has run, the wrapped key material files are available in a tmp folder as listed on screen and can be used to import the key as mentioned in the next step.
65
+
66
+
If you want to automate the import to OCI as well, the script has already some example code in it that can be used as a starting point for this. Just also make sure that you setup OCI Permissions and grant these to the compute's instance principles via a dynamic group. See the OCI Documentation for more details on permissions [here](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/Content/KeyManagement/Tasks/importingkeys.htm#permissions).
67
+
68
+
## Import the wrapped key material
50
69
51
-
-From the OCI Vault where the Public Wrapping Key was retrieved, create a Key and select the RSA as Key Shape Algorithm with the length 2048.
52
-
- Have hte Import External key checkbox enabled.
70
+
-In the OCI Console from the OCI Vault where the Public Wrapping Key was retrieved, click Create a Key and select the RSA as Key Shape Algorithm with the length 2048.
71
+
- Have the Import External key checkbox enabled.
53
72
- The Wrapping Algorithm should be automatically set to "RSA_OAEP_AES_SHA256"
54
-
- Upload the wrapped key material file **wrapped_key_material.key**
73
+
- Upload the wrapped key material file ```wrapped_key_material.key```
55
74
- Click on the Create Key button.
75
+
- Make sure to cleanup the used files as private keys should never be left somewhere on a filesystem.
0 commit comments