You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.7 KiB
105 lines
2.7 KiB
# 고객사 설치용 RootCA/Intermediate 인증서 생성
|
|
|
|
## 0) 폴더 구조(권장)
|
|
|
|
```bash
|
|
pki/
|
|
root/
|
|
intermediate/
|
|
```
|
|
|
|
---
|
|
|
|
## 1) Root CA 만들기 (1회, 오프라인 보관 권장)
|
|
|
|
### 1-1) Root 개인키 생성 (암호화 권장)
|
|
|
|
```bash
|
|
mkdir -p pki/root
|
|
cd pki/root
|
|
|
|
openssl genrsa -aes256 -out rootca-kdn.key 4096
|
|
```
|
|
(Enter PEM pass phrase: 백세민1!)
|
|
|
|
### 1-2) Root 인증서(자기서명) 생성
|
|
|
|
```bash
|
|
openssl req -x509 -new -nodes -key rootca-kdn.key -sha256 -days 3650 -subj "/C=KR/O=BSM-LAB/CN=BSM-LAB KDN Root CA" -out rootca-kdn.crt
|
|
```
|
|
(Enter pass phrase for rootca-kdn.key: 백세민1!)
|
|
|
|
> RootCA `rootca.key` 파일은 bsm-lab 고객관리 서버에 저장
|
|
|
|
---
|
|
|
|
## 2) Intermediate CA 만들기 (고객사별로 1개씩 권장)
|
|
|
|
### 2-1) Intermediate 개인키 생성
|
|
|
|
```bash
|
|
mkdir -p ../intermediate
|
|
cd ../intermediate
|
|
|
|
openssl genrsa -aes256 -out intermediate.key 4096
|
|
```
|
|
|
|
### 2-2) Intermediate CSR 생성
|
|
|
|
```bash
|
|
openssl req -new \
|
|
-key intermediate.key \
|
|
-subj "/C=KR/O=BSM-LAB/CN=BSM-LAB Customer Intermediate CA" \
|
|
-out intermediate.csr
|
|
```
|
|
|
|
### 2-3) Root로 Intermediate 인증서 서명
|
|
|
|
여기서 `v3_intermediate_ca` 확장(Constraints/KeyUsage)을 꼭 넣는 게 좋습니다. 간단히 쓸 수 있는 `root-ext.cnf` 파일을 하나 만듭니다.
|
|
|
|
**(root-ext.cnf)**
|
|
|
|
```ini
|
|
[ v3_intermediate_ca ]
|
|
basicConstraints = critical, CA:true, pathlen:0
|
|
keyUsage = critical, keyCertSign, cRLSign
|
|
subjectKeyIdentifier = hash
|
|
authorityKeyIdentifier = keyid:always,issuer
|
|
```
|
|
|
|
이제 Root로 서명:
|
|
|
|
```bash
|
|
# root 폴더로 돌아가 Root 키/인증서로 서명
|
|
cd ../root
|
|
|
|
openssl x509 -req -in ../intermediate/intermediate.csr \
|
|
-CA rootca.crt -CAkey rootca.key -CAcreateserial \
|
|
-out ../intermediate/intermediate.crt \
|
|
-days 1825 -sha256 \
|
|
-extfile root-ext.cnf -extensions v3_intermediate_ca
|
|
```
|
|
|
|
### 2-4) CA 체인 파일 만들기
|
|
|
|
```bash
|
|
cat ../intermediate/intermediate.crt rootca.crt > ../intermediate/ca-chain.crt
|
|
```
|
|
|
|
이 `ca-chain.crt`가 “고객사 설치용 CA 체인”으로 자주 쓰입니다(신뢰 저장소에 넣기 좋음).
|
|
|
|
---
|
|
|
|
## 3) 다음 단계(참고): leaf(에이전트/웹서버) 발급은 Intermediate로
|
|
|
|
CA 체인이 준비되면, leaf는 보통 이런 흐름입니다.
|
|
|
|
1. (에이전트/웹서버) 개인키 생성
|
|
2. CSR 생성(CN/SAN 포함)
|
|
3. **Intermediate로 서명**해서 leaf cert 발급
|
|
4. `leaf cert + private key`는 keystore(p12), `ca-chain`은 truststore에
|
|
|
|
---
|
|
|
|
원하시면, 위걸 “고객사 A/B별로 자동으로 디렉토리 생성해서 CA 체인 뽑는 스크립트(Windows PowerShell / Linux bash)”로 만들어드릴게요. 그리고 이어서 **leaf 인증서 발급 시 SAN(호스트/IP) 넣는 방법**까지 같이 붙이면 실제 배포에 바로 쓸 수 있습니다.
|