Red Hat Training

A Red Hat training course is available for RHEL 8

3.4. OpenSSL을 사용하여 TLS 클라이언트 인증서의 개인 키와 CSR 생성

TLS 암호화 통신 채널은 CA(인증 기관)의 유효한 TLS 인증서가 있는 경우에만 사용할 수 있습니다. 인증서를 받으려면 먼저 클라이언트의 개인 키와 CSR(인증서 서명 요청)을 생성해야 합니다.

절차

  1. 클라이언트 시스템에서 개인 키를 생성합니다. 예를 들면 다음과 같습니다.

    $ openssl genpkey -algorithm ec -pkeyopt ec_paramgen_curve:P-256 -out <client-private.key>
  2. 선택 사항: 선택한 텍스트 편집기를 사용하여 CSR 생성을 간소화하는 구성 파일을 준비합니다. 예를 들면 다음과 같습니다.

    $ vim <example_client.cnf>
    [client-cert]
    keyUsage = critical, digitalSignature, keyEncipherment
    extendedKeyUsage = clientAuth
    subjectAltName = @alt_name
    
    [req]
    distinguished_name = dn
    prompt = no
    
    [dn]
    CN = <client.example.com>
    
    [clnt_alt_name]
    email= <client@example.com>

    extendedKeyUsage = clientAuth 옵션은 인증서 사용을 제한합니다.

  3. 이전에 생성한 개인 키를 사용하여 CSR을 생성합니다.

    $ openssl req -key <client-private.key> -config <example_client.cnf> -new -out <client-cert.csr>

    -config 옵션을 생략하면 req 유틸리티에서 추가 정보를 입력하라는 메시지를 표시합니다. 예를 들면 다음과 같습니다.

    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    …
    Common Name (eg, your name or your server's hostname) []: <client.example.com>
    Email Address []: <client@example.com>

다음 단계

검증

  1. 사용자가 읽을 수 있는 인증서 부분이 요구 사항과 일치하는지 확인합니다. 예를 들면 다음과 같습니다.

    $ openssl x509 -text -noout -in <client-cert.crt>
    Certificate:
    …
                X509v3 Extended Key Usage:
                    TLS Web Client Authentication
                X509v3 Subject Alternative Name:
                    email:client@example.com
    …

추가 리소스

  • openssl(1), x509(1), genpkey(1), req(1), and config(5) man pages