![OpenSSL 구성 파일에서 기본 디렉터리가 작동하지 않음](https://rvso.com/image/154454/OpenSSL%20%EA%B5%AC%EC%84%B1%20%ED%8C%8C%EC%9D%BC%EC%97%90%EC%84%9C%20%EA%B8%B0%EB%B3%B8%20%EB%94%94%EB%A0%89%ED%84%B0%EB%A6%AC%EA%B0%80%20%EC%9E%91%EB%8F%99%ED%95%98%EC%A7%80%20%EC%95%8A%EC%9D%8C.png)
/etc/ssl/openssl.cnf 파일에 디렉토리를 설정했지만 명령을 실행할 때마다
openssl req -x509 -newkey rsa:4096 -keyout cakey.pem -out cacert.pem -days 3650
내가 작업 중인 디렉토리의 루트 디렉토리에 파일을 배치합니다.
[ CA_default ]
dir = /home/will/myCA # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
#unique_subject = no # Set to 'no' to allow creation of
# several certs with same subject.
new_certs_dir = $dir/newcerts # default place for new certs.
certificate = $dir/cacert.pem # The CA certificate
serial = $dir/serial # The current serial number
crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
private_key = $dir/private/cakey.pem# The private key
RANDFILE = $dir/private/.rand # private random number file
x509_extensions = usr_cert # The extensions to add to the cert
# Comment out the following two lines for the "traditional"
# (and highly broken) format.
name_opt = ca_default # Subject Name options
cert_opt = ca_default # Certificate field options
# Extension copying option: use with caution.
# copy_extensions = copy
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crlnumber must also be commented out to leave a V1 CRL.
# crl_extensions = crl_ext
default_days = 365 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = default # use public key default MD
preserve = no # keep passed DN ordering
# A few difference way of specifying how similar the request should look
# For type CA, the listed attributes must be the same, and the optional
# and supplied fields are just that :-)
policy = policy_match
디렉토리가 작동했다면 나는 이것을 기대해야합니다
Generating a 2048 bit RSA private key
.................................+++
.................................................................................................+++
writing new private key to '/home/will/myCA/private/cakey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
'/home/will/myCA/private/cakey.pem'에 새 개인 키 쓰기
바이너리를 사용하여 웹 사이트에서 직접 OpenSSL 버전을 업그레이드했으며 이제 /etc/local/ssl에 설치되었습니다. 불행하게도 OpenSSL로 생성한 파일이 폴더/디렉토리로 정렬되지 않는 이유를 아직도 이해하지 못합니다.
기본 디렉토리가 작동하지 않는 이유를 아는 사람이 있습니까?
많은 감사
할 것이다
업데이트 11:00 2019년 5월 30일
나는 명령을 실행했다
openssl req -x509 -newkey rsa:4096 -days 3650
하지만 터미널 창 내부에 키만 인쇄하고 파일로 출력하지 않습니다.
명령에 -noout을 추가했지만 파일이 ~privkey.pem에 저장되었으며 openssl.cnf 파일 /home/will/demoCA에 설정한 디렉토리에는 저장되지 않았습니다.
터미널이 열려 있는 작업 디렉터리에 파일이 저장되어 있는 것을 확인했습니다.
명령을 사용하면 openssl version -d
디렉터리를 설정한 구성 파일의 기본 위치가 표시됩니다.OPENSSLDIR: "/usr/local/ssl"
답변1
가 가리키는 파일은 명령 [ CA_defaults ]
에 의해 내부적으로 사용됩니다 openssl ca
.
내부를 살펴보면 명령 new_certs_dir
을 사용할 때 CA에서 서명한 모든 인증서가 표시되며 openssl ca
파일 이름은 인증서 일련 번호가 .pem
추가되어 구성됩니다.
사용 중에는 openssl req
해당 파일이 사용되지 않습니다.
명령 의 매뉴얼 페이지에는 req
다음과 같은 내용이 있습니다.
-out 파일 이름
이는 기본적으로 쓸 출력 파일 이름이나 표준 출력을 지정합니다.
따라서 주어진 파일 이름에 기록하고 명령을 실행하는 디렉터리에 위치합니다. 아니면 표준 출력에 쓸 것입니다.
-키아웃 파일 이름
새로 생성된 개인 키를 쓸 파일 이름이 제공됩니다. 이 옵션을 지정하지 않으면 구성 파일에 있는 파일 이름이 사용됩니다.
그러면 명령을 실행 중인 디렉터리에 다시 위치한 지정된 파일 이름에 기록됩니다. 또는 옵션에 지정된 파일 이름에 기록됩니다 default_keyfile
( [ req ]
물론 아래).
두 경우 모두 현재 디렉터리에 파일을 배치하지 않으려면 명령에 파일의 절대 경로를 제공할 수 있습니다.
파일에 구성한 구조는 명령을 사용하여 하위(CA 또는 최종 엔터티)의 요청에 서명할 .conf
때 작동합니다 . openssl ca
그러나 인증서에 서명할 수 있는 단계로 이동하려면 CA 인증서와 키가 필요합니다. 귀하의 openssl req
명령이 이를 생성합니다. CA 인증서에서 합리적인 값을 얻으려면 .conf
파일에 더 많은 것을 추가해야 합니다.
다음과 유사한 내용을 시작하면 됩니다.
[ req ]
# Don't prompt for the DN, use configured values instead
# This saves having to type in your DN each time.
prompt = no
string_mask = default
distinguished_name = req_dn
# The size of the keys in bits:
default_bits = 4096
[ req_dn ]
countryName = GB
stateOrProvinceName = Somewhere
organizationName = Example
organizationalUnitName = PKI
commonName = Example Test Root CA
[ ca_ext ]
# Extensions added to the request
basicConstraints = critical, CA:TRUE
keyUsage = critical, keyCertSign, cRLSign
이전 명령을 약간 수정하여 CA 인증서를 만듭니다.
openssl req -x509 -newkey rsa:4096 -keyout /home/will/myCA/private/cakey.pem -out /home/will/myCA/cacert.pem -days 3650 -nodes -config <path-to>/openssl.cnf -extensions ca_ext
-config
참고: 기본 구성 파일을 사용/편집하지 않는 경우에만 이 옵션이 필요합니다 .
모든 것이 제대로 작동하면 위의 CA 구성에 대한 올바른 인증서와 키가 있는 것입니다. 명령을 사용하여 인증서에 서명하기 전에 존재하는지 openssl ca
확인 하고 초기 일련 번호(예: )를 사용하여 index.txt
생성 해야 합니다 .serial
01
OpenSSL은 스위스 군용 암호화폐 칼이므로 다양한 옵션이 있습니다. 불행하게도 매뉴얼 페이지를 읽는 것이 그것을 이해하는 유일한 방법입니다.