2017-05-19 2 views
0

Windows 클라이언트에서 사용할 때 원격 서버에 완벽하게 연결할 수있는 .pfx 파일이 있습니다. 나는 이제 리눅스 클라이언트를 사용하여 서버에 연결하려고한다."sslv3 경고 핸드 셰이크 실패 : SSL 경고 번호 40"으로 SSL 핸드 셰이크가 발생하지 않습니다.

문제 1) 나는 OpenSSL이 공개 인증서와 PFX 파일에서 개인 키를 추출하는 명령 다음 사용

openssl pkcs12 -in Name.pfx -nocerts -out priv.pem -nodes 
openssl pkcs12 -in Name.pfx -nokeys -out pub.pem 

을하지만 두 파일의 MD5를 확인하기 위해이 명령을 다음 실행했을 때, 나는 그들 모두를 발견 다른.

openssl rsa -noout -text -in priv.pem | openssl md5 
openssl x509 -noout -text -in pub.pem | openssl md5 

문제 2) 내가 대신 인증서와 키를 모두 가지고 PFX에서 하나의 PEM 파일을 추출하려면 다음 명령을 사용했다.

openssl pkcs12 -in Name.pfx -out bundle.pem 

다음 명령을 사용하여, 내가 원격 서버에 접속을 시도이 PEM 파일을 사용하여 :

openssl s_client -servername 1.2.3.4 -connect 1.2.3.4:1234 -CAfile bundle.pem -state -tls1_2 

이 핸드 셰이크가 왜 파악하지 못할 터미널

CONNECTED(00000003) 
SSL_connect:before/connect initialization 
SSL_connect:SSLv3 write client hello A 
SSL_connect:SSLv3 read server hello A 
depth=0 O = "My Name", CN = Name - Local 
verify return:1 
SSL_connect:SSLv3 read server certificate A 
SSL_connect:SSLv3 read server key exchange A 
SSL_connect:SSLv3 read server certificate request A 
SSL_connect:SSLv3 read server done A 
SSL_connect:SSLv3 write client certificate A 
SSL_connect:SSLv3 write client key exchange A 
SSL_connect:SSLv3 write change cipher spec A 
SSL_connect:SSLv3 write finished A 
SSL_connect:SSLv3 flush data 
SSL3 alert read:fatal:handshake failure 
SSL_connect:failed in SSLv3 read finished A 
140250807310240:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:s3_pkt.c:1275:SSL alert number 40 
140250807310240:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:598: 
--- 
Certificate chain 
0 s:/O=My Name /CN=Name - Local 
    i:/O=My Name /CN=Name - Local 
--- 
Server certificate 
-----BEGIN CERTIFICATE----- 
<random string of certificate> 
-----END CERTIFICATE----- 
subject=/O=My Name /CN=Name - Local 
issuer=/O=My Name /CN=Name - Local 
--- 
No client certificate CA names sent 
Server Temp Key: ECDH, secp521r1, 521 bits 
--- 
SSL handshake has read 1332 bytes and written 206 bytes 
--- 
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384 
Server public key is 2048 bit 
Secure Renegotiation IS supported 
Compression: NONE 
Expansion: NONE 
SSL-Session: 
    Protocol : TLSv1.2 
    Cipher : ECDHE-RSA-AES256-GCM-SHA384 
    Session-ID: <some string> 
    Session-ID-ctx: 
    Master-Key: <some string> 
    Key-Arg : None 
    Krb5 Principal: None 
    PSK identity: None 
    PSK identity hint: None 
    Start Time: 1495217834 
    Timeout : 7200 (sec) 
    Verify return code: 0 (ok) 
--- 

에 다음과 같은 출력을 제공합니다 실패. 정확히 문제가있는 곳에서 3 일 동안 붙어 있습니다.

답변

1

But when I ran following two commands to verify md5 of both files, I found both of them different.

openssl rsa -noout -text -in priv.pem | openssl md5 
openssl x509 -noout -text -in pub.pem | openssl md5 

첫 번째 명령은 개인 키에 대한 텍스트 정보를 표시합니다. 공개 키가 들어있는 인증서에 대한 두 번째 텍스트 정보입니다. 물론이 정보는 다릅니다.

Using this pem file I tried connecting to the remote server, with following command :

openssl s_client -servername 1.2.3.4 -connect 1.2.3.4:1234 -CAfile bundle.pem -state -tls1_2 

인증서를 신뢰할 수있는 CA (-CAfile)로 사용합니다. 이것은 아마도 당신이 원하는 것이 아닙니다. 대신 인증서를 클라이언트 인증서로 사용하려고합니다. 이 경우 및 -key 옵션 (예 : -cert bundle.pem -key bundle.pem)을 사용하여 as documented을 입력해야합니다.

이외에도 -servername은 IP 주소가 아닌 호스트 이름이어야합니다. 호스트 이름이없는 경우이 옵션을 건너 뜁니다.

SSL_connect:SSLv3 read server certificate request A 
... 
SSL_connect:SSLv3 write client certificate A 
... 
SSL3 alert read:fatal:handshake failure 

클라이언트 인증서를 올바르게 지정하지 않으므로 빈 클라이언트 인증서가 전송됩니다. 그러나 서버는 유효한 클라이언트 인증서를 기대하므로 SSL 경고 내에서 실패한 핸드 셰이크를 클라이언트에보고합니다.

+0

하지만 두 파일의 md5 출력이 같아야한다는 기사 (예 : https://kb.wisc.edu/middleware/page.php?id=4064)가 있습니다. 또한 CAfile 플래그를 제거하고 제안 된대로 cert & key 플래그를 사용했습니다. 터미널은 암호문을 묻고 "오류 설정 개인 키 140495240427424 : 오류 : 0B080074 : x509 인증서 루틴 : X509_check_private_key : 키 값이 일치하지 않음 : x509_cmp.c : 331 :" –

+0

@AbhayJain : 사용자가 옵션을 사용 중입니다. '-text'. 당신이 참조하는 기사에서'-modulus' 옵션이 대신 사용됩니다. 마지막 옵션을 사용하면 첫 번째 옵션이 아닌 결과가 동일해야합니다. –

+0

@AbhayJain : 다른 문제는 https://stackoverflow.com/questions/4658484/ssl-install-problem-key-value-mismatch-but-they-do-match –

관련 문제