Apache 구성을 위한 SSL 인증서 유형 식별

Apache 구성을 위한 SSL 인증서 유형 식별

SSL 인증서 파일이 있습니다.

  • 루트2023.crt
  • t1.crt
  • t1.pem
  • t1.pk8

내 아파치에서 SSLCertificateFile, SSLCertificateKeyFile 및 SSLCertificateChainFile 등에 어떤 파일을 사용해야 하는지 어떻게 결정할 수 있습니까?

000-default.conf:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html



        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        SSLEngine on
        SSLCertificateFile /etc/ssl/t1.crt
        SSLCertificateKeyFile /etc/ssl/t1.pem
        SSLCertificateKeyFile /etc/ssl/t1.pk8
        SSLCertificateChainFile /etc/ssl/Root2023.crt

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

이 구성을 시도했지만 작동하지 않습니다

업데이트:

openssl x509 -in t1.pem -text -noout
openssl x509 -in t1.crt -text -noout
has similar output like this:

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 508... (0x468dc...8)
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN = rcii
        Validity
            Not Before: Feb 14 07:34:00 2023 GMT
            Not After : Feb 14 07:34:00 2026 GMT
        Subject: C = IR, ST = TEH, L = TEH, CN = 172.....
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (4096 bit)
                Modulus:
                    00:c4:.....

                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Key Usage:
                Digital Signature, Non Repudiation, Key Encipherment, Data Encipherment, Key Agreement
            X509v3 Extended Key Usage:
                TLS Web Server Authentication, TLS Web Client Authentication
            X509v3 Subject Alternative Name:
                IP Address:172.....
            Netscape Comment:
                xca certificate
    Signature Algorithm: sha256WithRSAEncryption
    Signature Value:
        34:bd:9

t1.pk8에 암호 문구가 있습니다

openssl rsa -in t1.pk8 -text -noout

산출:

Private-Key: (4096 bit, 2 primes)
modulus:
    00:c4:58:f7:e8:bf:ad:f1:f9:aa:33:e7:3c:b3:48:
publicExponent: 65537 (0x10001)
privateExponent:
    65:a0:6b:08:84:15:c3:55:e7:3b:a0:27:31:e0:74:
prime1:
    00:f2:e1:d3:4e:3f:2e:b3:69:60:cd:8c:8c:78:91:
prime2:
    00:ce:f3:bd:36:44:6e:bd:ae:65:43:62:59:8a:ec:
    af:03
exponent1:
    00:e1:cd:10:a5:ae:17:bc:b4:3b:4a:dd:5f:ba:b7:
    63:0d:e2:0b:18:93:35:8b:3c:df:4b:7e:d5:63:84:
    75
exponent2:
    1f:b9:21:21:f6:6f:7b:48:06:61:c3:eb:b1:ed:fc:
    7d
coefficient:
    37:ff:02:03:bf:37:c0:7f:6f:f8:a6:b1:51:9b:b3:
    fd:cf:fd:49:e3:c5:fb:6d:47:79:a0:0e:2d:99:50:
    eb

답변1

그만큼mod_ssl각 매개변수에 대한 문서는 예상되는 내용을 알려주며, 이는 귀하의 질문에 어느 정도 대답합니다.

개인 키

SSLCertificateKeyFile지령

설명: 서버 PEM 인코딩 개인 키 파일

이 지시문은 서버의 PEM 인코딩 개인 키 파일 또는 구성된 암호화 토큰을 통한 키 ID를 가리킵니다. 포함된 개인 키가 암호화된 경우 시작 시 암호 문구 대화 상자가 강제로 표시됩니다.

여기에 필요한 정보 가 t1.pk8포함되어 있지만 Apache를 다시 시작할 때마다 메시지가 표시되지 않도록 비밀번호를 제거할 수 있습니다.

openssl rsa -in /etc/ssl/t1.pk8 -out /etc/ssl/t1.key

결과 파일은 -----BEGIN PRIVATE KEY----.

키 파일은 더 이상 비밀번호로 보호되지 않으므로 파일 시스템 권한으로 보호해야 합니다.

chown root:root /etc/ssl/t1.key
chmod 600 /etc/ssl/t1.key

인증서 체인

SSLCertificateChainFile더 이상 사용되지 않습니다

SSLCertificateChainFileSSLCertificateFile서버 인증서 파일에서 중간 CA 인증서도 로드하도록 확장되었을 때 버전 2.4.8에서는 더 이상 사용되지 않습니다 .

그것은 자명해야합니다. 구성에서 이 지시문을 완전히 제거하십시오.

SSLCertificateFile지령

설명: 서버 PEM으로 인코딩된 X.509 인증서 데이터 파일 또는 토큰 식별자

이 지시문은 PEM 형식의 인증서 데이터가 있는 파일 또는 구성된 암호화 토큰을 통한 인증서 식별자를 가리킵니다. PEM 파일을 사용하는 경우 파일에는 최소한 최종 엔터티(리프) 인증서가 포함되어야 합니다. - -

파일에는 리프에서 루트로 정렬된 중간 CA 인증서가 포함될 수도 있습니다.

귀하가 t1.crt에 의해 직접 서명되었고 Root2023.crtRoot2023.crt클라이언트의 CA 저장소에 있는 경우 t1.crt그대로 사용할 수 있습니다.

필요한 것이 있으면중급인증서를 사용하려면 리프부터 루트까지 모두 포함하는 결합 파일을 만들어야 합니다. Root2023.crt중간 인증서가 포함된 파일이고 둘 다 이미 PEM 형식인 경우 다음과 결합할 수 있습니다.

cat /etc/ssl/t1.crt /etc/ssl/Root2023.crt > /etc/ssl/fullchain.pem

결과 파일은 다음과 같이 구성되어야 합니다.

-----BEGIN CERTIFICATE-----
Base 64 encoded contents of the leaf certificate.
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
Base 64 encoded contents of an intermediate certificate.
-----END CERTIFICATE-----

그 다음에는 필요한 양의 중간체(및 선택적으로 CA 인증서)가 옵니다.

구성

이제 이 지침이 귀하의 요구 사항에 적합하고 지침을 따랐다면 구성은 다음과 같을 것입니다.

    SSLEngine on
    SSLCertificateFile /etc/ssl/fullchain.pem
    SSLCertificateKeyFile /etc/ssl/t1.key

관련 정보