RAD 11월 14일, 2022에 포스트됨 공유하기 11월 14일, 2022에 포스트됨 원문제목: Keeping secrets on Amazon Web Services 원문: https://blogs.embarcadero.com/keeping-secrets-on-amazon-web-services/ 작성자: Richard Hatherall (2022.10) Keeping secrets can be tricky. Thankfully, Amazon Web Services has several tools in its toolbox to help. Let’s start by talking about AWS Secrets Manager and then go on to show how you can work easily with Amazon secrets in your Delphi cross-platform apps. 암호 관리는 까다로울 수 있는 작업이다. 다행히도, 아마존 웹 서비스는 이를 지원하는 자체 도구인 AWS Secrets Manager를 제공하며, 이에 대해 살펴보려고 한다. 그리고 여러분의 델파이 크로스 플랫폼 앱에서 아마존 암호 관리를 쉽게 활용할 수 있는 방법을 알아보겠다. 목차 AWS Secrets Manager란 무엇인가? AWS 키 관리 서비스(AWS KMS, AWS Key Management Service)란? 델파이와 AWS 연동 관련 정보는 어디에서 확인할 수 있을까? 델파이용 Appercept AWS SDK AWS Secrets Manager란 무엇인가? AWS Secrets Manager is exactly what it sounds like. Secrets Manager is the go-to place when you need to store something secret on Amazon Web Services, like a password for a database. You create a secret and retrieve it when needed in its most straightforward usage. Let’s look at how we can do that in Delphi. AWS Secrets Manager는 이름 그대로, 아마존 웹 서비스에 무언가를 저장해야 할 때 사용할 수 있는 도구로 일종의 데이터베이스용 패스워드라고 보면된다. 가장 일반적인 사용 방법은 암호 생성과 암호 검색이다. 델파이에서의 활용 방법을 살펴보자. program KeepItSecret; {$APPTYPE CONSOLE} uses AWS.SecretsManager; var SecretsManager: ISecretsManagerClient; Request: ISecretsManagerCreateSecretRequest; Response: ISecretsManagerCreateSecretResponse; begin Request := TSecretsManagerCreateSecretRequest.Create( 'prod/MyApp/MyDBPassword', 'MyVerySecretPassword' ); SecretsManager := TSecretsManagerClient.Create; Response := SecretsManager.CreateSecret(Request); if Response.IsSuccessful then Writeln('Secret safely stored.') else Writeln('There was a problem storing your secret.'); end. This program will store a password “MyVerySecretPassword” in AWS Secrets Manager in the current AWS region under the name “prod/MyApplication/MyDBPassword”. 여기에서는 현재 AWS의 AWS Secrets Manager에 있는 “prod/MyApplication/MyDBPassword” 이름에 암호 "MyVerySecretPassword"가 저장될 것이다. NOTE: It is good practice to use a naming convention for your secrets, like in this case, “Deployment Stage/Application Name/Application Secret Name”. So, now we have a secret stored, let’s look at how to get it back when we need it. 참고: 이 경우 "배포 단계/애플리케이션 이름/애플리케이션 암호명"으로 명명 규칙을 사용하는 것이 좋다. 이제 암호 저장이 완료되었으며, 필요할 때 확인하는 방법을 알아보겠다. program RetrieveSecret; {$APPTYPE CONSOLE} uses AWS.SecretsManager; var SecretsManager: ISecretsManagerClient; Response: ISecretsManagerGetSecretValueResponse; begin SecretsManager := TSecretsManagerClient.Create; Response := SecretsManager.GetSecretValue('prod/MyApp/MyDBPassword'); if Response.IsSuccessful then Writeln('Your secret is: ' + Response.SecretString) else Writeln('Could not retrieve your secret.'); end. This is Secrets Manager working in its simplest form. Secrets Manager is a high-level service capable of organising secrets with meta-data, automatically rotating secrets on a specified schedule, all neatly taken care of. So, cryptography is a complicated business; how does Secrets Manager handle encryption keeping all the necessary complexity hidden? The answer is AWS Key Management Service (AWS KMS), let’s talk about KMS… 위는 가장 간단한 형태의 Secrets Manager 작동 방식이다. Secrets Manager는 메타 데이터로 암호를 정리할 수 있는 높은 수준의 서비스로, 지정된 일정에 암호를 자동으로 전환하도록 하며, 이 모든 작업이 완벽하게 작동한다. 암호화는 복잡한 비즈니스이다. Secrets Manager는 요구되는 복잡성을 모두 충족하는 암호를 어떻게 관리할 수 있을까? 그 답은 AWS 키 관리 서비스(AWS KMS)이다. KMS를 알아보자. AWS 키 관리 서비스(AWS KMS, AWS Key Management Service)란? AWS Key Management Service is the service other AWS services use when they need cryptographic services. Amazon S3 uses it to enable encryption-at-rest for stored objects, and Amazon Simple Email Service uses KMS to store messages encrypted-at-rest, to name a couple of examples. AWS 키 관리 서비스는 다른 AWS 서비스에서 암호화 서비스가 필요할 때 활용할 수 있다. 아마존 S3에서 이를 활용해 저장 오브젝트에 대한 유휴 상태 암호화를 설정할 수 있다. 그리고 아마존 간편 이메일 서비스(Amazon Simple Email Service)는 KMS를 통해 유휴 상태의 암호화된 메세지를 저장하고, 여러 샘플을 명명할 수 있다. Each AWS service that uses KMS stores an encryption key generated for your account in each region under an alias; for example, Secrets Manager uses the alias aws/secretsmanager. In addition to AWS services, you can generate and store your own encryption keys on KMS for your purposes. Let’s look at how you can create an encryption key, use it to encrypt some simple text data, and decrypt the encrypted data. KMS를 활용하는 AWS 서비스는 각 지역에 있는 계정용으로 생성된 암호화 키를 별칭(alias)에 저장한다. 예를 들어, Secrets Manager는 별칭 aws/secretsmanager를 사용한다. AWS 서비스 외에도 KMS에 필요에 맞게 자체 암호화 키를 저장하거나 생성할 수 있다. 암호화 키를 생성하는 방법과 단순 텍스트 데이터를 암호화하는 방법, 암호화된 데이터를 해독하는 방법을 살펴보겠다. program EncryptIt; {$APPTYPE CONSOLE} uses AWS.KMS, System.Classes, System.SysUtils; var KMS: IKMSClient; CreateKeyRequest: IKMSCreateKeyRequest; CreateKeyResponse: IKMSCreateKeyResponse; CreateAliasResponse: IKMSCreateAliasResponse; EncryptRequest: IKMSEncryptRequest; EncryptResponse: IKMSEncryptResponse; DecryptRequest: IKMSDecryptRequest; DecryptResponse: IKMSDecryptResponse; DecryptedText: TStringStream; begin KMS := TKMSClient.Create; try // Create a KMS key. CreateKeyRequest := TKMSCreateKeyRequest.Create; CreateKeyResponse := KMS.CreateKey(CreateKeyRequest); // Create an alias so I can remember my key. CreateAliasResponse := KMS.CreateAlias('alias/MyApp', CreateKeyResponse.KeyMetadata.KeyId); // Encrypt some text. EncryptRequest := TKMSEncryptRequest.Create('alias/MyApp', 'My secret...'); EncryptResponse := KMS.Encrypt(EncryptRequest); if EncryptResponse.IsSuccessful then begin Writeln( Format( 'Encrypted secret. Received %d bytes.', [EncryptResponse.CiphertextBlob.Size] ) ); // Let's decrypt the CiphertextBlob and output the text. DecryptRequest := TKMSDecryptRequest.Create(EncryptResponse.CiphertextBlob); DecryptResponse := KMS.Decrypt(DecryptRequest); if DecryptResponse.IsSuccessful then begin DecryptedText := TStringStream.Create; try DecryptedText.CopyFrom(DecryptResponse.Plaintext); Writeln(Format('Decrypted: "%s"', [DecryptedText.DataString])); finally DecryptedText.Free; end; end; end; except on E: EKMSException do Writeln(E.ClassName, ': ', E.Message); end; end. In the following example, we use the key’s alias alias/MyApp to reference the encryption key when decrypting the value. Using an alias makes the key easy to locate in future operations. 키의 별칭 alias/MyApp을 사용해 해독할 때 암호화 키를 참조해보겠다. 별칭을 사용하면 이후 작업에서 키의 위치를 쉽게 파악할 수 있다. You may wonder why you’d choose to use KMS over Secrets Manager; after all, these programs do basically the same thing. The answer is a combination of costs and features. Secrets Manager is easier to use, but there is a cost per secret stored, currently $0.40/secret/month, where KMS is charged per key, which could be used to encrypt/decrypt many secrets. If you’re looking for a simple, managed solution that handles secret rotation and has integrations with services like Amazon Relational Database Service (RDS), then Secrets Manager is worth the money. If you’re looking for general-purpose cryptography features like encryption, decryption, signing and verification, then KMS is what you need. Secrets Manager보다 KMS 사용 검토가 필요한 이유가 궁금할 것이다. 결국, 이 프로그램들은 모두 기본적으로 같은 일을 한다. 그럼 기능과 비용을 살펴보아야한다. Secrets Manager는 사용법이 더 쉽지만 저장 암호 당 비용이 부과된다. 현재는 매월 암호당 $0.40이 청구된다. 반면 KMS는 암호의 암호화/해독에 사용 가능한 키 값당 비용이 청구된다. 단순하면서도 관리형 솔루션을 찾고있고, 아마존 관계형 데이터베이스 서비스(RDS) 등 관련 서비스와 통합하고 암호 전환을 핸들링하고 싶다면, Secrets Manager가 더 유용할 것이다. 그리고 암호화, 해독, 서명, 검증 등 다목적 암호화 기능이 필요하다면, KMS가 맞을 것이다. 델파이와 AWS 연동 관련 정보는 어디에서 확인할 수 있을까? A sample project, “Secrets Manager Console”, is available on GitHub in the AWS SDK for Delphi Samples repository, demonstrating some of the features of AWS Secrets Manager and AWS KMS. 샘플 프로젝트 "Secrets Manager Console"은 깃허브(GitHub) AWS SDK 델파이 샘플 저장소에서 확인할 수 있다. AWS Secrets Manager와 AWS KMS 기능을 살펴볼 수 있다. To learn more about the features of AWS Secrets Manager, read the AWS Secrets Manager User Guide. AWS Secrets Manager 기능을 더 자세히 알고싶다면, AWS Secrets Manager 사용자 가이드를 읽어보길 바란다. Read the AWS Key Management Service User Guide to learn what AWS Key Management Service (AWS KMS) offers. AWS Key Management Service 사용자 가이드에서 AWS Key Management Service(AWS KMS) 기능들을 확인할 수 있다. 델파이용 Appercept AWS SDK Appercept AWS SDK for Delphi is available exclusively on GetIt with active Enterprise or Architect subscriptions for Embarcadero Delphi or RAD Studio. You can install the SDK through the GetIt Package Manager within Delphi or RAD Studio if you have an active subscription. 델파이용 Appercept AWS SDK(한글자료)는 엠바카데로 델파이 또는 RAD스튜디오의 엔터프라이즈 또는 아키텍트 에디션 업데이트 서브스크립션 계약중인 고객이라면 누구나 겟잇(GetIt)에서 받아 사용할 수 있다. 델파이, RAD스튜디오를 실행하고 겟잇 패키지 매니저(GetIt Package Manager)에서 SDK를 실행하면 된다. Appercept AWS SDK로 할 수 있는 작업을 알고싶다면, 아래 링크를 살펴보기 바란다: Amazon Textract로 이미지에 있는 텍스트 검색 및 추출하기 Amazon Polly로 크로스 플랫폼 앱에서 텍스트를 음성으로 손쉽게 변환하기 앱 내 AWS SES Natively 사용에 필요한 모든 것 인용하기 이 댓글 링크 다른 사이트에 공유하기 더 많은 공유 선택 사항
Recommended Posts
이 토의에 참여하세요
지금 바로 의견을 남길 수 있습니다. 그리고 나서 가입해도 됩니다. 이미 회원이라면, 지금 로그인하고 본인 계정으로 의견을 남기세요.