개발자-H 입니다.

Openssl genrsa - RSA 키쌍을 생성 본문

Security/Openssl

Openssl genrsa - RSA 키쌍을 생성

개발자-H 2023. 1. 30. 06:30

 

Openssl genrsa 명령어로 개인키, 공개키를 생성 할수 있음

 

  • 샘플 스크립트
# RSA 키쌍 생성 크기는 2048
# openssl genrsa [개인키 암호화 방식] -out [개인키 출력 파일명] 개인키 길이
openssl genrsa -aes256 -out dwarfHan.pkey 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
........................................................+++++
............+++++
e is 65537 (0x010001)

# 개인키 비밀번호 입력
# 비밀번호가 너무 짧으면 에러 나옴
Enter pass phrase for dwarfHan.pkey:

# 개인키 비밀번호 입력 확인
Verifying - Enter pass phrase for dwarfHan.pkey:

# 생성된 비밀번호 확인
cat dwarfHan.pkey

# RSA 개인키 PEM 형식으로 저장 
# PEM 헤더 정보 (Proc-Type, DEF-Info)로 개인키에 비밀번호가 걸려있는 것을 확인
# 개인키로 암호화 된 정보가 Base64 형태로 저장됨
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,42920E5D63FC52D1747326FACC2CF1D9

LStQPjcFSENcoNkYBbtFmex6AYwaZSfQrOka9CjOqK2dn54vRs0x9AHzXiWZVtKE
aTPZOefLf+WcNeMoz9xmKVkf0n7M6kjcE4dXFixrnIB6Ng4pEa9+6qc+co8a7aG7
hrR3FXp/sf8LxE834DQCrleCn60euZmVaZSLvDQUK4RS8M/eJOOVTJ4bQpNgnnor
l5RUPcbr+0YEiQqe/EovLIOnow1ZBjbmAktjwTHZnYINJlENa9wiS2Hi7zF5eVR/
JbSLRY5Ez1NjGficLiVIsOi7mwbgiT7mm8c5a2uGv8V1xeC0trRpKmnsA81uRgU8
kmFS0ZMAgd0HDhKrl6iYFwobffH6KPTFY3MvOR2+k5txBF5QLBmLKWEVueo7F+Pq
5U6iMDLrgZcf1g/U1izjp5pVNkPVDk9gOG5QRF8fslurmfVIw11lQ6G87dQhJYKC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xue2V4djrrAZJjcq5/1cxFMo9
M6VobSXDTfDneVRn5M9lWQIngEJAK72MNKQyL1rdB0s+jOdxpSf9VRIP+2UuBydY
-----END RSA PRIVATE KEY-----

 

 

 

OpenSSL 로 SSL/TLS 용 인증서 요청 및 발급받기

Enter pass phrase for lesstif.com.key: You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you

www.lesstif.com

 

'Security > Openssl' 카테고리의 다른 글

Openssl x509 - 인증서 정보 출력  (1) 2023.01.28
Comments