TLS套接字服务器名属性

时间:2018-08-14 21:29:40

标签: ios macos security ssl curl

如果我使用cURL版本7.54.0(x86_64-apple-darwin17.0)向服务器发出https请求,我会注意到servername属性设置为false,但是访问令牌返回。

client: 
TLSSocket {
 _tlsOptions: 
  { secureContext: [Object],
    isServer: true,
    server: [Object],
    requestCert: false,
    rejectUnauthorized: true,
    handshakeTimeout: 120000,
    NPNProtocols: <Buffer 08 68 74 74 70 2f 31 2e 31 08 68 74 74 70 2f 31 2e 30>,
    ALPNProtocols: <Buffer 08 68 74 74 70 2f 31 2e 31>,
    SNICallback: [Function: SNICallback] },
 _secureEstablished: true,
 _securePending: false,
 _newSessionPending: false,
 _controlReleased: true,
 _SNICallback: null,
 servername: false,
 npnProtocol: false,
 alpnProtocol: 'http/1.1',
 authorized: false,
 authorizationError: null,
 encrypted: true,

如果我使用iOS URLRequest发出相同的请求,则servername属性将设置为请求中host的IP地址。

 client: 
 TLSSocket {
 _tlsOptions: 
  { secureContext: [Object],
    isServer: true,
    server: [Object],
    requestCert: false,
    rejectUnauthorized: true,
    handshakeTimeout: 120000,
    NPNProtocols: <Buffer 08 68 74 74 70 2f 31 2e 31 08 68 74 74 70 2f 31 2e 30>,
    ALPNProtocols: <Buffer 08 68 74 74 70 2f 31 2e 31>,
    SNICallback: [Function: SNICallback] },
 _secureEstablished: true,
 _securePending: false,
 _newSessionPending: false,
 _controlReleased: true,
 _SNICallback: null,
 servername: '192.168.0.127',
 npnProtocol: false,
 alpnProtocol: 'http/1.1',
 authorized: false,
 authorizationError: null,
 encrypted: true,

服务器名是我在整个请求对象中唯一看到的差异。对于两个请求,这也都使用了自签名证书。

我的问题是:是否可以将servername属性设置为false或为空,以允许我的请求通过而无需尝试重​​写iOS套接字层协议?

0 个答案:

没有答案