리눅스/명령어
한 줄 명령으로 자체 서명된 SSL 인증서를 생성하는 방법
코드버스
2023. 3. 20. 20:29
728x90
반응형
한 줄 명령으로 자체 서명된 SSL 인증서를 생성하는 방법
Common Name(CN)은 예시로 "example.com"을 사용합니다.
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 \
-keyout example.key -out example.crt \
-subj "/C=US/ST=California/L=Los Angeles/O=Example Company/OU=IT Department/CN=example.com"
위 명령어는 다음과 같은 역할을 합니다.
- -new: 새로운 CSR(Certificate Signing Request)을 생성합니다.
- -newkey rsa:2048: RSA 알고리즘을 사용하여 2048비트 개인키를 생성합니다.
- -days 365: 인증서의 유효 기간을 365일로 설정합니다.
- -nodes: 개인키를 암호화하지 않습니다.
- -x509: 자체 서명된 SSL 인증서를 생성합니다.
- -keyout example.key: 개인키를 example.key 파일에 저장합니다.
- -out example.crt: SSL 인증서를 example.crt 파일에 저장합니다.
- -subj "/C=US/ST=California/L=Los Angeles/O=Example Company/OU=IT Department/CN=example.com": SSL 인증서의 subject 정보를 설정합니다. 여기서 Common Name(CN)은 example.com으로 설정됩니다.
이 명령어를 실행하면, 개인키와 SSL 인증서가 각각 example.key와 example.crt 파일에 생성됩니다. 이제 이를 사용하여 웹 서버나 다른 서비스를 보안 연결로 설정할 수 있습니다.
codeverse.kr 도메인으로 자체 서명된 SSL 인증서 생성
$ openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -out server.crt -subj "/C=KR/ST=Seoul/L=Jongno-gu/O=it blog platform/CN=codeverse.kr"
...+.................+.......+........+....+.....+....+......+...........+...+.+...+.....+......+....+..+......+...+....+......+.........+.....+.............+..+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*......+.....+...+.........+......+..........+..+..........+..+....+.....+.+...+...............+..+.+........+.+........+......+.+......+.....+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...........................+.......+.....+.........+.........+...+....+...+..+......+.............+..+..........+.................+.+......+...........+....+......+...+......+.....+.+...+..+............+...+...+.....................+......+.......+.....+.+.....+.......+...+......+.....+.........+.+.........+.....+.........+................+.....+.......+.....+.............+..+...+............+....+.....+.........+......+......+....+......+.........+......+...+...........+....+..............+...............+......+....+..+.+...............+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
..........+.....+.......+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+....+...........+.+.....+.........+.........+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
$ ls -l | grep server
-rw-r--r-- 1 root root 1326 Mar 20 20:33 server.crt
-rw------- 1 root root 1704 Mar 20 20:33 server.key
$ openssl x509 -in server.crt -noout -subject -enddate
subject=C = KR, ST = Seoul, L = Jongno-gu, O = it blog platform, CN = codeverse.kr
notAfter=Mar 19 11:33:07 2024 GMT
728x90
반응형