Openssl重新谈判失败

时间:2018-04-12 08:56:26

标签: ssl openssl tls1.2 handshake gnutls

我正在尝试将openssl客户端连接到服务器。我正在使用以下命令:     openssl s_client -cipher“AES256”-connect 15.213.94.8:6433 -msg

输出是:

CONNECTED(00000003)
>>> TLS 1.2 Handshake [length 00ce], ClientHello
01 00 00 ca 03 03 f1 77 45 36 0d 10 84 27 a3 11
04 81 07 78 84 39 46 a2 de 44 53 8b b9 01 fd 57
14 d9 fe 67 61 ab 00 00 34 c0 30 c0 2c c0 28 c0
24 c0 14 c0 0a 00 a3 00 9f 00 6b 00 6a 00 39 00
38 c0 19 00 a7 00 6d 00 3a c0 32 c0 2e c0 2a c0
26 c0 0f c0 05 00 9d 00 3d 00 35 00 ff 01 00 00
6d 00 0b 00 04 03 00 01 02 00 0a 00 34 00 32 00
0e 00 0d 00 19 00 0b 00 0c 00 18 00 09 00 0a 00
16 00 17 00 08 00 06 00 07 00 14 00 15 00 04 00
05 00 12 00 13 00 01 00 02 00 03 00 0f 00 10 00
11 00 23 00 00 00 0d 00 20 00 1e 06 01 06 02 06
03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 03
02 03 03 02 01 02 02 02 03 00 0f 00 01 01
<<< TLS 1.2 Handshake [length 0051], ServerHello
02 00 00 4d 03 03 5a ce f7 9f 32 15 3b 2b 7e 75
8d 02 6f ff e9 d1 44 e4 6f 05 cd 1c ec 70 0c 7c
d2 05 d2 b5 27 f5 20 6a 45 e2 43 62 20 e9 48 0e
aa fc 7e 2e c4 5b c6 0a 6d dd 7d b6 71 7d 05 a0
4c 60 09 61 1d 24 69 00 6b 00 00 05 ff 01 00 01
00
<<< TLS 1.2 Handshake [length 033f], Certificate
0b 00 03 3b 00 03 38 00 03 35 30 82 03 31 30 82
02 9a a0 03 02 01 02 02 04 5a cc 5e 97 30 0d 06
09 2a 86 48 86 f7 0d 01 01 05 05 00 30 81 dc 31
10 30 0e 06 03 55 04 0a 13 07 6e 73 73 74 73 31
34 31 34 30 32 06 03 55 04 0b 13 2b 47 65 6e 65
72 61 74 65 64 20 54 75 65 20 41 70 72 20 31 30
20 31 32 3a 31 39 3a 35 36 20 55 54 43 2b 2d 35
3a 2d 20 32 30 31 38 31 23 30 21 06 03 55 04 0b
13 1a 4e 6f 20 41 73 73 75 72 61 6e 63 65 20 2d
20 53 65 6c 66 2d 53 69 67 6e 65 64 31 3c 30 3a
06 03 55 04 0b 13 33 54 65 73 74 69 6e 67 20 4f
6e 6c 79 20 2d 20 44 6f 20 4e 6f 74 20 54 72 75
73 74 20 66 6f 72 20 53 65 63 75 72 65 20 54 72
61 6e 73 61 63 74 69 6f 6e 73 31 2f 30 2d 06 03
55 04 03 13 26 53 65 63 75 72 65 20 54 72 61 6e
73 70 6f 72 74 20 42 6f 6f 74 73 74 72 61 70 20
43 65 72 74 69 66 69 63 61 74 65 30 1e 17 0d 31
38 30 34 31 30 30 36 34 39 35 39 5a 17 0d 31 38
30 37 30 39 30 36 34 39 35 39 5a 30 81 dc 31 10
30 0e 06 03 55 04 0a 13 07 6e 73 73 74 73 31 34
31 34 30 32 06 03 55 04 0b 13 2b 47 65 6e 65 72
61 74 65 64 20 54 75 65 20 41 70 72 20 31 30 20
31 32 3a 31 39 3a 35 36 20 55 54 43 2b 2d 35 3a
2d 20 32 30 31 38 31 23 30 21 06 03 55 04 0b 13
1a 4e 6f 20 41 73 73 75 72 61 6e 63 65 20 2d 20
53 65 6c 66 2d 53 69 67 6e 65 64 31 3c 30 3a 06
03 55 04 0b 13 33 54 65 73 74 69 6e 67 20 4f 6e
6c 79 20 2d 20 44 6f 20 4e 6f 74 20 54 72 75 73
74 20 66 6f 72 20 53 65 63 75 72 65 20 54 72 61
6e 73 61 63 74 69 6f 6e 73 31 2f 30 2d 06 03 55
04 03 13 26 53 65 63 75 72 65 20 54 72 61 6e 73
70 6f 72 74 20 42 6f 6f 74 73 74 72 61 70 20 43
65 72 74 69 66 69 63 61 74 65 30 81 9f 30 0d 06
09 2a 86 48 86 f7 0d 01 01 01 05 00 03 81 8d 00
30 81 89 02 81 81 00 a0 80 77 3c 87 c4 f2 a0 23
ea 3c c2 03 90 e5 1f 07 2b da e0 3a 54 4f 54 b1
1b 99 07 e3 31 e8 fc ea c0 2c 1b 3b b1 2c b2 81
dc 52 4f 01 6c 86 72 26 e9 2f e5 51 e9 88 5f c5
da 74 1e 9c b2 f1 29 ce b2 b9 b3 af 1a 64 ce 47
df 5b 6b 0c b1 ad 2d 05 9e bf 97 42 a9 26 e9 92
f7 6c 15 23 bd fa 94 2f e6 54 2e 27 d3 dd ef 92
7e 3a 21 55 98 db 65 63 6c 3f ca a1 3b d7 e6 5e
09 77 0d 40 dc ad 5f 02 03 01 00 01 30 0d 06 09
2a 86 48 86 f7 0d 01 01 05 05 00 03 81 81 00 6e
18 05 ad 39 bc 64 47 b6 50 56 c2 6e da 4a db a4
f9 10 9a 86 63 4f 99 b5 36 93 7b 7a 59 78 b2 21
d7 50 a1 18 cc 08 81 a4 13 8e ce d5 03 13 0b 53
97 76 80 6b b2 3f e2 15 ad ca b4 ac fa 49 a5 70
e2 d8 5a 3e 43 eb 3d 28 7e 27 47 a7 df 27 e2 5a
29 1a 6a ba ef 32 56 fe 0f f5 00 dc fe 6c af fb
df c7 fe 0c b2 93 d9 99 6e 03 ae f7 9b cc 43 6f
7c 85 d8 65 11 96 fc a1 4b ee 25 d4 e6 0a 8c
depth=0 O = nssts99, OU = "Generated Tue Apr 10 12:19:56 UTC+-5:- 2018", OU = No Assurance - Self-Signed, OU = Testing Only - Do Not Trust for Secure Transactions, CN = Secure Transport Bootstrap Certificate
verify error:num=18:self signed certificate
verify return:1
depth=0 O = nssts99, OU = "Generated Tue Apr 10 12:19:56 UTC+-5:- 2018", OU = No Assurance - Self-Signed, OU = Testing Only - Do Not Trust for Secure Transactions, CN = Secure Transport Bootstrap Certificate
verify return:1
<<< TLS 1.2 Handshake [length 020e], ServerKeyExchange
0c 00 02 0a 00 80 84 cd 7a 4d c7 91 c6 75 30 c3
05 c9 d9 04 d4 4c 20 a5 52 e2 52 0e f1 7d 0c 3c
6a 98 75 91 ac 51 17 a5 45 1a 58 90 8e af 2b ac
29 f9 bd 39 33 a1 bd b2 cc 91 5b d6 49 19 98 fa
d4 b7 e7 7e 58 35 6c 83 fc 4b 63 e6 e9 96 aa 83
2b 44 f4 be fa dc c0 31 fa 61 58 49 bf 2f bc f5
82 b0 ab 8f b2 1d b4 87 a2 6e 3b e6 15 ef 5b fc
77 29 88 a7 5f fa 0d 9f 91 9e 25 33 21 c4 fa d6
5a 2b e9 dc 1f 17 00 80 42 93 80 8f 55 ab e4 1b
71 a2 d2 ec 93 5b 37 c5 71 36 cc 4f ab 06 d8 8f
63 48 23 2f f3 d6 34 e0 d5 f7 7a e6 f8 2e 0b 94
12 0b 4f d7 62 1c 9d 33 83 c5 cd 7c b0 c8 24 76
19 be a5 50 12 c7 77 e6 a8 85 53 18 36 e4 4d 4b
27 0b 0a 73 4a b6 33 8b 47 9c 94 d3 be b2 02 35
72 b0 15 62 26 b6 04 8e 73 2e eb e4 39 ea 14 8f
cd f8 28 16 74 20 02 30 cc 26 5f 16 c7 f2 92 7f
6d e0 cd 31 aa 60 93 d6 00 80 84 af 04 c2 f5 45
6c c6 a0 87 89 cd b3 dd 68 79 fe 4f ba c5 e2 db
0e 32 12 36 14 e9 e6 a3 ca 3f 87 bf 6a 89 32 f3
68 14 50 b1 b0 50 3f 3a ee 79 72 53 c7 3c 2c 5b
86 0e 2d e6 c3 15 d4 03 8a 6b 1f 03 05 89 88 9a
0a d9 ea 4c 3c 7a c7 8f af 40 b2 c8 a3 fe b2 db
43 e7 0e b3 4b b9 43 03 f6 97 46 33 57 ec fe 64
de f2 3b 60 b8 09 7e 5d 02 b0 51 21 4e 05 22 08
f6 ee 0d 27 2e 47 89 6a 9f e5 06 01 00 80 53 af
c7 d1 d3 63 d3 19 5f 3e a6 10 47 4c c5 dc 36 f8
7e 4d d0 a3 ce 1b 42 a8 cc 54 01 ac fc 95 85 3e
75 11 6d 2f 9a a0 67 65 e9 3e f2 f6 c2 00 91 4b
48 9d 8c 83 4b d7 a7 37 83 29 10 5d 2d f5 d8 4e
28 23 8e 7a e8 b6 23 75 3b 57 8d 3a 69 62 8a db
69 86 a4 79 5e 2c d0 0a e6 41 7c b4 38 a4 11 6e
f1 10 93 06 ae 23 3c 32 8f 9d 7b 19 25 44 1c cb
91 ea c5 89 a6 58 c8 bf c8 f0 ee 94 cd ce
<<< TLS 1.2 Handshake [length 0004], ServerHelloDone
0e 00 00 00
>>> TLS 1.2 Handshake [length 0086], ClientKeyExchange
10 00 00 82 00 80 10 95 d8 9b 00 89 95 f2 b6 2e
a5 98 00 88 fa 1b 42 5c ac 75 33 42 1c 0f 32 e7
d6 c7 95 81 07 e0 23 e5 bf d2 99 4a f6 16 81 31
95 64 59 c0 2f b8 52 08 16 e2 45 08 0a df 65 25
b5 5d 2d 7e e6 bb 46 d3 29 a5 74 1a d9 d1 99 57
c0 ea af d4 2f 22 14 5b 8a fa f6 b9 32 15 fe 32
2b b7 a1 82 b8 08 b6 9b 3d e2 7b 33 71 89 f2 48
7e 4d 82 24 e4 14 96 86 d5 db 0c c1 55 03 6a ff
bc 16 58 f1 b6 bc
>>> TLS 1.2 ChangeCipherSpec [length 0001]
01
>>> TLS 1.2 Handshake [length 0010], Finished
14 00 00 0c 52 16 05 75 ee db 9a 44 dc cc 6c bf
<<< TLS 1.2 ChangeCipherSpec [length 0001]
01
<<< TLS 1.2 Handshake [length 0010], Finished 
14 00 00 0c 70 6b 32 0a 7e d5 ae 05 64 8b 88 ac---
Certificate chain
0 s:/O=nssts99/OU=Generated Tue Apr 10 12:19:56 UTC+-5:-2018/OU=No Assurance 
Self-Signed/OU=Testing Only - Do Not Trust for Secure Transactions/CN=Secure
i:/O=nssts99/OU=Generated Tue Apr 10 12:19:56 UTC+-5:- 2018/OU=No Assurance 
Self-Signed/OU=Testing Only - Do Not Trust for Secure Transactions/CN=Secure
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDMTCCApqgAwIBAgIEWsxelzANBgkqhkiG9w0BAQUFADCB3DEQMA4GA1UEChMH
bnNzdHMxNDE0MDIGA1UECxMrR2VuZXJhdGVkIFR1ZSBBcHIgMTAgMTI6MTk6NTYg
VVRDKy01Oi0gMjAxODEjMCEGA1UECxMaTm8gQXNzdXJhbmNlIC0gU2VsZi1TaWdu
bmNlIC0gU2VsZi1TaWduZWQxPDA6BgNVBAsTM1Rlc3RpbmcgT25seSAtIERvIE5v
dCBUcnVzdCBmb3IgU2VjdXJlIFRyYW5zYWN0aW9uczEvMC0GA1UEAxMmU2VjdXJl
l0KpJumS92wVI736lC/mVC4n093vkn46IVWY22VjbD/KoTvX5l4Jdw1A3K1fAgMB
AAEwDQYJKoZIhvcNAQEFBQADgYEAbhgFrTm8ZEe2UFbCbtpK26T5EJqGY0+ZtTaT
e3pZeLIh11ChGMwIgaQTjs7VAxMLU5d2gGuyP+IVrcq0rPpJpXDi2Fo+Q+s9KH4n
R6ffJ+JaKRpquu8yVv4P9QDc/myv+9/H/gyyk9mZbgOu95vMQ298hdhlEZb8oUvu
JdTmCow=
-----END CERTIFICATE-----
subject=/O=nssts14/OU=Generated Tue Apr 10 12:19:56 UTC+-5:- 2018/OU=No 
Assurance - Self-Signed/OU=Testing Only - Do Not Trust for Secure    Transactions/CN=Secure
issuer=/O=nssts14/OU=Generated Tue Apr 10 12:19:56 UTC+-5:- 2018/OU=No   Assurance - Self-Signed/OU=Testing Only - Do Not Trust for Secure  Transactions/CN=Secure

No client certificate CA names sent

SSL handshake has read 1569 bytes and written 441 bytes

New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA256
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
      Protocol  : TLSv1.2
      Cipher    : DHE-RSA-AES256-SHA256
      Session-ID: 6A45E2436220E9480EAAFC7E2EC45BC60A6DDD7DB6717D05A04C6009611D2469
      Session-ID-ctx:
      Master-Key: 
3DDDE131C8480BC508F529263A14648AE2F6DFE9D3687AB6A9E5803D77E9FFF7
3C81B2BB836E1FAB4987EE67D0B238A0
      Key-Arg   : None
      PSK identity: None
      PSK identity hint: None
      SRP username: None
      Start Time: 1523513247
      Timeout   : 300 (sec)
      Verify return code: 18 (self signed certificate)
-------------------------------------------------

上面,它表示支持重新谈判。现在,当我将R作为“重新协商”的输入时,我得到以下输出:

R
RENEGOTIATING
>>> TLS 1.2 Handshake [length 00dd], ClientHello
    01 00 00 d9 03 03 5b 61 2b 1f e8 81 a3 04 04 3b
    d1 d0 b5 f6 11 6f 2c 73 72 ac 04 62 8d 84 a9 e5
    fb bf 8e 2d 0e cb 00 00 32 c0 30 c0 2c c0 28 c0
    24 c0 14 c0 0a 00 a3 00 9f 00 6b 00 6a 00 39 00
    38 c0 19 00 a7 00 6d 00 3a c0 32 c0 2e c0 2a c0
    26 c0 0f c0 05 00 9d 00 3d 00 35 01 00 00 7e ff
    01 00 0d 0c 52 16 05 75 ee db 9a 44 dc cc 6c bf
    00 0b 00 04 03 00 01 02 00 0a 00 34 00 32 00 0e
    00 0d 00 19 00 0b 00 0c 00 18 00 09 00 0a 00 16
    00 17 00 08 00 06 00 07 00 14 00 15 00 04 00 05
    00 12 00 13 00 01 00 02 00 03 00 0f 00 10 00 11
    00 23 00 00 00 0d 00 20 00 1e 06 01 06 02 06 03
    05 01 05 02 05 03 04 01 04 02 04 03 03 01 03 02
    03 03 02 01 02 02 02 03 00 0f 00 01 01
<<< TLS 1.2 Alert [length 0002], warning close_notify
    01 00
1825587648:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake 
failure:/home/ravi/101jssl-h01/openssl-1.0.1j/ssl/s3_pkt.c:615:

为什么会出现ssl3_write_bytes错误和握手失败?

1 个答案:

答案 0 :(得分:0)

从日志中可以明显看出,服务器未正确处理第一条消息“ TLS 1.2握手[length 00dd],ClientHello”,并且未发送 ServerHello 消息,因此它将发送警报通知关闭与客户端的连接。客户端收到警报消息,并调用ssl3_write_bytes处理该消息。并且当前状态仍在TLS重新协商中。因此,将调用握手函数,并发出错误消息,因为预期不会收到消息。这在code

中非常清楚
int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
{
const unsigned char *buf=buf_;
unsigned int n,nw;
int i,tot;

s->rwstate=SSL_NOTHING;
OPENSSL_assert(s->s3->wnum <= INT_MAX);
tot=s->s3->wnum;
s->s3->wnum=0;

if (SSL_in_init(s) && !s->in_handshake)
    {
    i=s->handshake_func(s);
    if (i < 0) return(i);
    if (i == 0)
        {
        SSLerr(SSL_F_SSL3_WRITE_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);
        return -1;
        }
     }
 ......