您当前的位置: 首页 >  面试
  • 0浏览

    0关注

    674博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

面试:IP直连的问题

沙漠一只雕得儿得儿 发布时间:2021-12-20 20:28:08 ,浏览量:0

IP直连的好处
  1. 省去DNS解析过程,减少耗时;
  2. 就近接入,减少耗时;
  3. 避免DNS劫持;
  4. 终端有多个IP接入时,有容灾能力;
IP直连存在的问题:

HTTPS IP直连问题小结_leelit笔记本-CSDN博客_https ip

  1. 证书HOST校验问题; 证书校验用的是域名校验,而不是iP地址,OkHostnameVerifier替换为域名;
  2. SNI问题; 一个域名对应多个iP地址,证书校验时没有找到自己设置的IP地址,报错,在SSLSocketFactory的实现类中设置自己的域名;
  3. 连接复用问题; 具体判断是否可复用问题在RealConnection#isEligible();
  4. 兼容性问题;
  5. Session复用问题
boolean equalsNonHost(Address that) {
    return this.dns.equals(that.dns)
        && this.proxyAuthenticator.equals(that.proxyAuthenticator)
        && this.protocols.equals(that.protocols)
        && this.connectionSpecs.equals(that.connectionSpecs)
        && this.proxySelector.equals(that.proxySelector)
        && equal(this.proxy, that.proxy)
        && equal(this.sslSocketFactory, that.sslSocketFactory)
        && equal(this.hostnameVerifier, that.hostnameVerifier)
        && equal(this.certificatePinner, that.certificatePinner)
        && this.url().port() == that.url().port();
  }

&& equal(this.sslSocketFactory, that.sslSocketFactory) && equal(this.hostnameVerifier, that.hostnameVerifier)

https 不支持ip地址?

的确不支持。为啥呢?

拿百度地址为例。访问百度的ip地址,就提示证书不信任,不匹配。原因是:一般来说证书都是以域名为标示的,跟访问的ip地址肯定不匹配。如图

关注
打赏
1657159701
查看更多评论
立即登录/注册

微信扫码登录

0.0398s