尝试使用python(使用platform.lifelog.sonymobile.com:443库)或requests到达openssl时,我遇到SSL握手失败。

这是我从openssl得到的输出

ssl3:

$ >openssl s_client -connect platform.lifelog.sonymobile.com:443 -ssl3 -state
CONNECTED(00000003)
SSL_connect:before/connect initialization
SSL_connect:SSLv3 write client hello A
SSL3 alert read:fatal:handshake failure
SSL_connect:failed in SSLv3 read server hello A
3073824444:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:s3_pkt.c:1262:SSL alert number 40
3073824444:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:598:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 0 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
  Protocol  : SSLv3
  Cipher    : 0000
  Session-ID:
  Session-ID-ctx:
  Master-Key:
  Key-Arg   : None
  PSK identity: None
  PSK identity hint: None
  SRP username: None
  Start Time: 1464110874
  Timeout   : 7200 (sec)
  Verify return code: 0 (ok)
---


tlsv1.1:

$>openssl s_client -connect platform.lifelog.sonymobile.com:443 -tls1_1
CONNECTED(00000003)
3074041532:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert    handshake failure:s3_pkt.c:1262:SSL alert number 40
3074041532:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:598:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 0 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
  Protocol  : TLSv1.1
  Cipher    : 0000
  Session-ID:
  Session-ID-ctx:
  Master-Key:
  Key-Arg   : None
  PSK identity: None
  PSK identity hint: None
  SRP username: None
  Start Time: 1464110950
   Timeout   : 7200 (sec)
  Verify return code: 0 (ok)
---


tlsv1.2:

$>openssl s_client -connect platform.lifelog.sonymobile.com:443 -tls1_2
CONNECTED(00000003)
3074123452:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:s3_pkt.c:1262:SSL alert number 40
3074123452:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:598:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 0 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
   Protocol  : TLSv1.2
  Cipher    : 0000
  Session-ID:
  Session-ID-ctx:
  Master-Key:
  Key-Arg   : None
  PSK identity: None
  PSK identity hint: None
  SRP username: None
  Start Time: 1464110938
  Timeout   : 7200 (sec)
  Verify return code: 0 (ok)
---


我是否需要客户证明书或其他?
谢谢!

最佳答案

我正在使用https://github.com/google/google-oauth-java-client中的google-oauth-java-client定期从lifelog API中获取数据。证书不需要特别注意。在使用Android客户端之前,我先使用ARC(Chrome的其余客户端)测试了我的所有逻辑,还用curl做了一些测试,一旦获得这样的Bearer(您需要在Lifelog API文档中获取Authorization值):

curl 'https://platform.lifelog.sonymobile.com/v1/users/me/activities' \
  -H 'Pragma: no-cache' -H 'Accept-Encoding: gzip, deflate, sdch' \
  -H 'Accept-Language: es-419,es;q=0.8,en-US;q=0.6,en;q=0.4' \
  -H 'Authorization: Bearer AuyKFAzQar5xhgRHhHKlboApaRKH' \
  -H 'Accept: */*' -H 'Cache-Control: no-cache' \
  -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36' \
  -H 'Cookie: BLABLA' -H 'Connection: keep-alive' --compressed

09-10 22:09