Cloud KMS로 키를 가져오려면 먼저 RSA-OAEP(OpenSSL 1.1에 기본적으로 포함되어 있음)와 패딩이 있는 AES 키 래핑(OpenSSL 1.1에 기본적으로 포함되어 있지 않음)을 모두 포함하는 PKCS#11CKM_RSA_AES_KEY_WRAP 스킴을 사용하여 키를 래핑해야 합니다. 이 메커니즘은 OpenSSL에 포함되지 않습니다.
가져오기가 진행되는 동안 Google Cloud CLI를 사용하여 각 키를 자동으로 래핑하는 것이 좋습니다. 규정 준수 또는 규제 요구사항으로 인해 키를 수동으로 래핑해야 하는 경우 먼저 OpenSSL을 다시 컴파일하여 패딩으로 AES 키 래핑을 지원해야 합니다. OpenSSL을 다시 컴파일한 후 수동으로 키를 래핑할 수 있습니다.
시작하기 전에
이 주제의 절차에 따라 생성된 패치가 적용된 바이너리로 시스템의 기본 제공 OpenSSL 바이너리를 덮어쓰지 마세요. 예를 들어, 패치가 적용된 OpenSSL을 /usr에 직접 설치하지 마세요. 이 절차를 정확하게 따르면 패치가 적용된 OpenSSL이 $HOME/build에 내장되어 $HOME/local/bin에 설치됩니다.
${HOME}/local/bin이 이미 있는 경우 이 항목의 단계를 수행하기 전에 콘텐츠를 백업하거나 파일을 다른 위치로 옮기세요.
OpenSSL v1.1.0 패치 및 설치
OpenSSL을 사용하여 키를 Cloud KMS로 가져오기 전에 수동으로 래핑하는 경우 OpenSSL v1.1.0이 필요하며 다음 패치가 적용됩니다. OpenSSL을 컴파일하고 시스템의 기본 OpenSSL 설치와 다른 위치에 설치해야 합니다.
https://www.openssl.org/source에서 OpenSSL 1.1.0l 버전의 소스를 다운로드합니다.
1.1.0 코드 행의 최신 출시 버전입니다. 이 절차에서 v1.1.1과 같은 그 이상 버전의 OpenSSL을 사용하지 마세요. 패치가 적용되지 않습니다.
다음 명령어를 사용하여 아카이브를 ${HOME}/build/openssl/에 추출합니다.
이 명령어는 OpenSSL 버전을 포함하는 기본 디렉터리를 재정의하며 자주 변경됩니다. /path/to/downloaded-openssl.tar.gz를 다운로드한 .tar.gz 아카이브의 경로로 바꿉니다.
# Create the directory for the eventual OpenSSL binaries
mkdir -p ${HOME}/local/ssl
# Create the build directory
mkdir -p ${HOME}/build/openssl
# Extract the archive to ${HOME}/build/openssl
tar xzvf /path/to/downloaded-openssl.tar.gz \
-C ${HOME}/build/openssl/ \
--strip-components 1
다음 명령어를 사용하여 압축을 푼 OpenSSL 소스에 커스텀 패치를 적용합니다. 패치는 EVP_CIPHER_CTX_FLAG_WRAP_ALLOW 플래그를 사용 설정합니다.
다음 명령어를 실행하여 패치가 적용된 소스에서 OpenSSL 바이너리 및 라이브러리를 빌드하고, 빌드의 유효성을 테스트하고, 바이너리 및 라이브러리를 ${HOME}/local 디렉터리에 설치합니다.
CPUS=$(getconf _NPROCESSORS_ONLN)
cd ${HOME}/build/openssl
./config --prefix=${HOME}/local --openssldir=${HOME}/local/ssl
make -j${CPUS}
make test
make install
--prefix 또는 --openssldir 플래그를 생략하거나 수정해서는 안됩니다. 시스템의 OpenSSL 설치를 덮어쓰지 않도록 합니다.
다음 명령어를 실행하여 새 OpenSSL 바이너리가 성공적으로 설치되었는지 확인합니다.
test -x ${HOME}/local/bin/openssl || echo FAIL
바이너리가 올바르게 설치되면 출력이 표시되지 않습니다. FAIL가 표시되면 이전에 실행한 make, make test, make install 명령어의 출력을 확인합니다.
패치가 적용된 OpenSSL 바이너리는 ${HOME}/local/ssl/lib/의 OpenSSL 라이브러리와 동적으로 연결되지만 ld 명령어는 기본적으로 이러한 라이브러리의 색인을 생성하지 않습니다. 다음 명령어를 실행하여 패치가 적용된 라이브러리를 ${LD_LIBRARY_PATH}에 추가하는 래퍼 스크립트를 생성한 다음 패치가 적용된 OpenSSL에 대해 CLI를 호출합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-05(UTC)"],[],[],null,["# Configuring OpenSSL for manual key wrapping\n\nBefore you can import a key into Cloud KMS, it must be wrapped\nusing the\n[PKCS#11](https://docs.oasis-open.org/pkcs11/pkcs11-curr/v2.40/cos01/pkcs11-curr-v2.40-cos01.html#_Toc408226908)\n`CKM_RSA_AES_KEY_WRAP` scheme, which includes both `RSA-OAEP` (which is included\nin OpenSSL 1.1 by default) and AES Key Wrap\nwith Padding (which is not). That mechanism is not included in OpenSSL.\n\nWe recommend using the Google Cloud CLI to\n[wrap each key automatically](/kms/docs/importing-a-key#request_import) during\nthe import. If you must wrap your keys manually due to compliance or regulatory\nrequirements, you must first recompile OpenSSL to add support for AES Key Wrap\nwith Padding. After recompiling OpenSSL, you can\n[wrap the key manually](/kms/docs/wrapping-a-key).\n| **Important:** If you use automatic wrapping, do not follow these steps. Instead, you need to [install the Pyca cryptographic library](/kms/docs/crypto), which works with the OpenSSL binaries already installed on your local system. The Google Cloud CLI can use that library to automatically wrap your key during the import request.\n\nBefore you begin\n----------------\n\n| **Caution:** These steps require advanced knowledge of Linux. Most users should allow the Google Cloud CLI command to [automatically wrap and import](/kms/docs/importing-a-key#automatically_wrap_and_import) keys instead of following the instructions in this topic.\n\nDo not overwrite your system's built-in OpenSSL binaries with the\npatched binaries produced by following the procedures in this topic. For example,\ndo not install the patched OpenSSL directly into `/usr`. If you follow this\nprocedure exactly, the patched OpenSSL is built in `$HOME/build` and installed\ninto `$HOME/local/bin`.\n\nIf `${HOME}/local/bin` already exists, back up its contents or move those files\nelsewhere before following the steps in this topic.\n\nPatch and install OpenSSL v1.1.0\n--------------------------------\n\nIf you choose to use OpenSSL to manually wrap your keys before importing them\ninto Cloud KMS, OpenSSL v1.1.0 is required, with the following\npatch applied. You will need to compile OpenSSL and install it into a location\nseparate from your system's default OpenSSL installation.\n\n1. Download the source for OpenSSL 1.1.0l release from\n [https://www.openssl.org/source](https://www.openssl.org/source/old/1.1.0/openssl-1.1.0l.tar.gz).\n This is the latest release in the 1.1.0 code line. Do not use a newer\n version of OpenSSL, such as v1.1.1, in this procedure. The patch will fail\n to apply.\n\n2. Extract the archive to `${HOME}/build/openssl/` using the following command.\n This command overrides the default directory, which includes the version of\n OpenSSL and changes often. Replace\n \u003cvar translate=\"no\"\u003e/path/to/downloaded-openssl.tar.gz\u003c/var\u003e with the path to the downloaded\n `.tar.gz` archive.\n\n ```\n # Create the directory for the eventual OpenSSL binaries\n mkdir -p ${HOME}/local/ssl\n\n # Create the build directory\n mkdir -p ${HOME}/build/openssl\n\n # Extract the archive to ${HOME}/build/openssl\n tar xzvf /path/to/downloaded-openssl.tar.gz \\\n -C ${HOME}/build/openssl/ \\\n --strip-components 1\n ```\n3. Apply a custom patch to the extracted OpenSSL source, using the following\n commands.The patch enables the `EVP_CIPHER_CTX_FLAG_WRAP_ALLOW` flag.\n\n | **Warning:** This patch fails to apply to versions of OpenSSL other than v1.1.0l.\n\n\n ```none\n cd ${HOME}/build\n cat \u003c\u003c-EOF | patch -d . -p0\n --- orig/openssl/apps/enc.c 2020-01-17 14:39:54.991708785 -0500\n +++ openssl/apps/enc.c 2020-01-17 14:41:33.215704269 -0500\n @@ -482,6 +482,7 @@\n */\n\n BIO_get_cipher_ctx(benc, &ctx);\n + EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);\n\n if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, enc)) {\n BIO_printf(bio_err, \"Error setting cipher %s\\n\",\n EOF\n ```\n\n \u003cbr /\u003e\n\n4. Run the following commands to build the OpenSSL binaries and libraries from\n the patched source, test the build for validity, and install the binaries\n and libraries into the `${HOME}/local` directory.\n\n ```none\n CPUS=$(getconf _NPROCESSORS_ONLN)\n cd ${HOME}/build/openssl\n ./config --prefix=${HOME}/local --openssldir=${HOME}/local/ssl\n make -j${CPUS}\n make test\n make install\n ```\n\n Do not omit or modify the `--prefix` or `--openssldir` flags, to ensure that\n you do not overwrite the system's OpenSSL installation.\n5. Run the following command to check that the new OpenSSL binary installed\n successfully:\n\n ```none\n test -x ${HOME}/local/bin/openssl || echo FAIL\n ```\n\n You should see no output if the binaries are installed correctly. If you see\n `FAIL`, check the output of the `make`, `make test`, and `make install`\n commands you ran earlier.\n6. The patched OpenSSL binaries are dynamically linked against the OpenSSL\n libraries in `${HOME}/local/ssl/lib/`, but the `ld` command does not\n index these libraries by default. Run the following commands to create a\n wrapper script that adds the patched libraries to the `${LD_LIBRARY_PATH}`\n before invoking the CLI for the patched OpenSSL.\n\n\n ```\n cat \u003e ${HOME}/local/bin/openssl.sh \u003c\u003c-EOF\n #!/bin/bash\n env LD_LIBRARY_PATH=${HOME}/local/lib/ ${HOME}/local/bin/openssl \"\\$@\"\n EOF\n chmod u+x ${HOME}/local/bin/openssl.sh\n ```\n\n \u003cbr /\u003e\n\n7. Check that the version of OpenSSL that the script starts is the version you\n just built and installed, using the following command:\n\n ```\n ${HOME}/local/bin/openssl.sh version\n ```\n\nYou can now invoke the `${HOME}/local/bin/openssl.sh` wrapper script to\n[manually wrap keys for import](/kms/docs/wrapping-a-key)."]]