SSL : 오류 : 0B080074 : x509 인증서 루틴 : X509_check_private_key : 키 값 불일치
SSL을 설정할 수 없습니다. 나는 구글을 검색했고 몇 가지 해결책을 찾았지만 그들 중 어느 것도 나를 위해 일하지 않았습니다. 도움이 필요 해요 ...
nginx를 다시 시작하려고 할 때 발생하는 오류는 다음과 같습니다.
root@s17925268:~# service nginx restart
Restarting nginx: nginx: [emerg] SSL_CTX_use_PrivateKey_file("/etc/nginx/conf.d/ssl/ssl.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
nginx: configuration file /etc/nginx/nginx.conf test failed
내 인증서는 StartSSL에서 가져온 것이며 1 년 동안 유효합니다.
내가 테스트 한 내용은 다음과 같습니다.
- 인증서와 개인 키에는 뒤에 공백이 없습니다.
- 기본 server.key 파일을 사용하지 않습니다.
- nginx.conf를 확인했고 지시문이 올바른 개인 키와 인증서를 가리키고 있습니다.
또한 모듈러스를 확인했고 키와 인증서에 대해 다른 모듈러스를 얻었습니다.
도와 주셔서 감사합니다. :)
키와 인증서에 대해 다른 결과를 가진 MD5 해시가 있습니다.
이것은 모든 것을 말합니다. 키와 인증서가 일치하지 않습니다.
계수가 일치해야합니다. 올바른 키가 있는지 확인하십시오.
일치하지 않는다는 것을 확인한 후에도 여전히 문제가 있습니다. 종종 인증서가 잘못 조립되었을 수 있습니다. CA가 인증서에 서명하면 다음과 같은 블록을 보냅니다.
-----BEGIN CERTIFICATE-----
MIIAA-and-a-buncha-nonsense-that-is-your-certificate
-and-a-buncha-nonsense-that-is-your-certificate-and-
a-buncha-nonsense-that-is-your-certificate-and-a-bun
cha-nonsense-that-is-your-certificate-and-a-buncha-n
onsense-that-is-your-certificate-AA+
-----END CERTIFICATE-----
또한 인증서를 부여 할 수있는 권한을 나타내는 번들 (종종 두 개의 인증서)을 보냅니다. 이것은 다음과 같이 보일 것입니다
-----BEGIN CERTIFICATE-----
MIICC-this-is-the-certificate-that-signed-your-request
-this-is-the-certificate-that-signed-your-request-this
-is-the-certificate-that-signed-your-request-this-is-t
he-certificate-that-signed-your-request-this-is-the-ce
rtificate-that-signed-your-request-A
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICC-this-is-the-certificate-that-signed-for-that-one
-this-is-the-certificate-that-signed-for-that-one-this
-is-the-certificate-that-signed-for-that-one-this-is-t
he-certificate-that-signed-for-that-one-this-is-the-ce
rtificate-that-signed-for-that-one-this-is-the-certifi
cate-that-signed-for-that-one-AA
-----END CERTIFICATE-----
안타깝게도 레이블이 명확하게 표시되지는 않습니다.
일반적인 관행은이 모든 것을 하나의 파일 (인증서, 서명 인증서)로 묶는 것입니다. 그러나 그들은 쉽게 구별되지 않기 때문에 누군가가 실수로 모르는 사이에 실수로 인증서에 서명 한 다음 최종 인증서에 다른 순서로 배치하는 경우가 있습니다. 이 경우 인증서는 키와 일치하지 않습니다.
다음을 실행하여 인증서가 무엇을 나타내는 지 테스트 할 수 있습니다.
openssl x509 -noout -text -in yourcert.cert
상단에 '제목 :'이 표시되고 데이터와 유사한 항목이 표시됩니다. 대신 CA처럼 보이면 번들 순서가 잘못되었을 수 있습니다. 백업을 만든 다음 마지막 인증서가 자신의 인증서가되기를 바라면서 처음으로 이동할 수 있습니다.
이것이 작동하지 않으면 인증서를 재발급 받아야 할 수도 있습니다. CSR을 만들 때 어떤 서버용인지 (ssl.key 또는 server.key 대신) 명확하게 레이블을 지정하고 mydomain.20150306.key 등과 같이 이름에 날짜가 포함 된 복사본을 만드는 것을 좋아합니다. 개인 및 공개 키 쌍은 다른 세트와 혼동 될 가능성이 낮습니다.
- 인증서와 키가 PEM 형식인지 확인하십시오. 그렇지 않은 경우 openssl 명령을 사용하여 변환하십시오.
공개 키의 MD5 해시를 확인하여 개인 키에있는 것과 일치하는지 확인하십시오.
openssl x509 -noout -modulus -in certificate.crt | openssl md5 openssl rsa -noout -modulus -in privateKey.key | openssl md5
번들과 인증서를 잘못된 순서로 추가했기 때문에이 문제가 발생하여 다른 사람에게 도움이 될 수 있습니다.
이전 (잘못된) :
cat ca_bundle.crt certificate.crt > bundle_chained.crt
이후 (맞습니다)
cat certificate.crt ca_bundle.crt > bundle_chained.crt
그리고 적절한 conf를 업데이트하는 것을 잊지 마십시오 (ssl_certificate는 이제 체인 된 crt를 가리켜 야합니다).
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate bundle_chained.crt;
ssl_certificate_key www.example.com.key;
...
}
From the nginx manpage:
If the server certificate and the bundle have been concatenated in the wrong order, nginx will fail to start and will display the error message:
SSL_CTX_use_PrivateKey_file(" ... /www.example.com.key") failed (SSL: error:0B080074:x509 certificate routines: X509_check_private_key:key values mismatch)
If this happens and you are using Let's Encrypt / certbot, the reason is most likely that you used chain.pem
instead of fullchain.pem
.
It should be something like this:
ssl_certificate /etc/certbot/live/example.com/fullchain.pem;
ssl_certificate_key /etc/certbot/live/example.com/privkey.pem;
See certbot docs “Where are my certificates?”
I had the same problem and finally resolved it by changing the order of pem blocks in certificate file.
The cert block should be put in the beginning of the file, then intermediate blocks, then root block.
I realized this problem by comparing a problematic certificate file with a working certificate file.
In my case I've wanted to change the ssl certificate, because I've e changed my server so I had to create a new csr with this command:
$openssl req -new -newkey rsa:2048 -nodes -keyout mysite.key -out mysite.csr
I have sent mysite.csr file to the company ssl provider and after I received the the certificate crt and then I've restarted nginx , and I have got this error
(SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
After a lot of investigation, the error was that module from key file was not the same with the one from crt file
So, in order to make it work I have created a new csr file but I have change the name of the file with this command
$openssl req -new -newkey rsa:2048 -nodes -keyout mysite_new.key -out mysite_new.csr
Then I had received a new crt file from the company provider, restart nginx and it worked.
My 5 cents on the issue:
I had same problem. After about 1 hour looking after it, I found I pasted the certificate incorrectly.
If you have error like this, please check your certificate.
This can also happen when your CA issues an intermediate cert
I ran into this issue (twice) with nginx and none of the solutions in this post explained the issue. The blog post here by a nice gentleman named Marco nailed it, and I am pasting it here for anyone who also runs into what I was seeing. https://medium.com/@mrkdsgn/steps-to-install-a-go-daddy-ssl-certificate-on-nginx-on-ubuntu-14-04-ff942b9fd7ff
In my case, go-daddy was the CA and this is specific to how they issue the cert and the intermediate cert bundles.
Here is the excerpt from Marco's blog post
With Nginx, if your CA included an intermediate certificate, you must create a single chained certificate file that contains your certificate and the CA’s intermediate certificates.
You can use this command to create a combined file called example.com.chained.crt:
cat example.com.crt intermediate.crt > example.com.chained.crt
For Nginx;
1- openssl req -newkey rsa:2048 -nodes -keyout domain.com.key -out domain.com.csr
2- SSL file domain_com.crt and domain_com.ca-bundle files copy new file in paste domain.com.chained.crt
3- Add nginx files: a. ssl_certificate /home/user/domain_ssl/domain.com.chained.crt; b. ssl_certificate_key /home/user/domain_ssl/domain.com.key;
Lates restart Nginx
Im my case the problem was that I cretead sertificates without entering any data in cli interface. When I regenerated cretificates and enetered all fields: City, State, etc all became fine.
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
It happened to me when I combined the bundle.crt and main cert. The reason was I copied the main cert below the bundle.crt. It should be the other way around
1/ main cert 2/ bundle.crt
'Programing' 카테고리의 다른 글
XmlSerializer를 사용하여 문자열을 CDATA로 직렬화하는 방법은 무엇입니까? (0) | 2020.09.23 |
---|---|
"실행기 활동이 없습니다!"라는 의미는 무엇입니까? (0) | 2020.09.23 |
RVM을 사용하여 Rails on Lion을 설치할 수없는 이유는 무엇입니까? (0) | 2020.09.22 |
Android의 Chrome에서 실제 화면 크기 / dpi / 픽셀 밀도 가져 오기 (0) | 2020.09.22 |
오류 : __karma __. start 메소드를 구현하는 일부 어댑터를 포함해야합니다. (0) | 2020.09.22 |