使用Local -Host HTTPS连接测试iOS应用程序不起作用



我这个周末我在这个周末去了圈子,不知道下一步去哪里。

背景:我想使用HTTPS对本地Tomcat服务器进行测试。我已经创建了自己的CA根证书和数字标识证书,但是当我在通过Xcode上连接我的XCODE上的XCODE上的tomcat服务器时,我会遇到错误。

我遇到的错误是:Nsurlorrordomain代码:184467444073709550416_KCFStreamErrorCodekey:-9800

(Xcode的屏幕截图(:Xcode

中的错误屏幕截图

设置:1(我在Localhost上(MacBook(上运行了一台Tomcat服务器。我已经安装了Xcode,并且正在模拟器上运行iOS应用程序;我还将物理iPhone绑在MacBook上。

我的server.xml文件如下:

2(我有一个在AWS上运行的tomcat服务器的镜子,并从SSLs.com上签名的键,一切都很好。

3(另外,我可以通过HTTP在本地主机上成功连接我的应用程序和我的tomcat服务器。

http://localhost:8080/thetest/thetest

4(我可以通过https与模拟器连接到我的tomcat。(以前我无法连接,并且在物理iPhone设备上遇到的错误类似。(

https://localhost:8443/thetest/thetest

证书:我遵循这些说明。
https://developer.apple.com/library/content/technotes/tn2326/_index.html#//apple_ref/doc/doc/uid/dts40014136

测试:a(我可以在MacBook上通过Chrome和Safari执行命令,并无问题地连接到我的Tomcat服务器。

请参阅Chrome上的Heresecure

b(我可以与我的iOS模拟器连接并无问题连接。

2018-02-18 10:07:26.741348-0800 folie [13634:1105541] [MC]懒负荷 nsbundle mobilecoreservices.framework

2018-02-18 10:07:26.742612-0800 folie [13634:1105541] [MC]加载 mobilecoreservices.framework

2018-02-18 10:07:30.068718-0800 folie [13634:1105541] [MC]系统组 systemgroup.com.apple.configurationprofiles路径的容器 /user/me/library/develicer/coresimulator/devices/7c6df662-d026-419f-bdec-96c130628095/data/data/containers/containers/shared/shared/shared/systemgroup/systemgroup/systemgroup/systemgroup/systemgroup.com.apple.configuratigle.configurationprofiles

2018-02-18 10:07:30.070359-0800 folie [13634:1105541] [MC] 私人有效的用户设置。

2018-02-18 10:07:32.203212-0800 Folie [13634:1105541] - [ViewController 注册:] -107

2018-02-18 10:07:40.315781-0800 Folie [13634:1106003]收到的数据 从注册按钮: hellotesting ...

c(当我在物理iOS设备上运行测试应用程序时,我将获得以下输出:

2018-02-18 09:50:26.555890-0800 folie[5058:1225079] [MC] Lazy loading NSBundle MobileCoreServices.framework
2018-02-18 09:50:26.558353-0800 folie[5058:1225079] [MC] Loaded MobileCoreServices.framework
2018-02-18 09:50:29.640089-0800 folie[5058:1225079] [MC] System group container for systemgroup.com.apple.configurationprofiles path

是 /private/var/containers/shared/systemgroup/systemgroup.com.apple.configurationprofiles

2018-02-18 09:50:29.642837-0800 folie[5058:1225079] [MC] Reading from public effective user settings.
2018-02-18 09:50:37.833201-0800 folie[5058:1225079] -[ViewController SignUp:] - 107
2018-02-18 09:50:42.444278-0800 folie[5058:1225149] [BoringSSL] Function nw_protocol_boringssl_handshake_negotiate_proceed: line 387

握手失败。断开会话

2018-02-18 09:50:42.446312-0800 folie[5058:1225149] TIC TCP Conn Failed [1:0x1c0165b80]: 3:-9800 Err(-9800)
2018-02-18 09:50:42.451062-0800 folie[5058:1225149] TIC TCP Conn Failed [2:0x1c4165100]: 3:-9800 Err(-9800)
2018-02-18 09:50:42.455194-0800 folie[5058:1225149] TIC TCP Conn Failed [3:0x1c4165340]: 3:-9800 Err(-9800)
2018-02-18 09:50:42.455519-0800 folie[5058:1225149] NSURLSession/NSURLConnection HTTP load failed

(kcfstreamerordomainssl,-9800(

2018-02-18 09:50:42.455650-0800 folie[5058:1225149] Task <B07F6A46-BE52-4439-A300-AF4C905AAD35>.<1> HTTP load failed (error

代码:-1200 [3:-9800](

2018-02-18 09:50:42.456039-0800 folie[5058:1225223] Task <B07F6A46-BE52-4439-A300-AF4C905AAD35>.<1> finished with error - code:

-1200

证书:iPhone和模拟器都安装了相同的根证书

sim

物理iPhone

d(我进行的最后一次测试是在绑好设备并关闭电池和WiFi之后,使用Chrome和Safari浏览器从物理设备访问Tomcat服务器。Safari没有显示页面,Chrome显示以下错误:ERR_SSL_PROTOCOL_ERROR

iPhone物理设备上的Chrome浏览器

解决方案是使用特定的主机名而不是localhost,如@rmaddy所建议的。

步骤:

  1. 编辑server.xml文件:
<Connector SSLEnabled="true"
           clientAuth="false"
             keyalias="**therealhostname**"
         keystoreFile="conf/teststorespec.jks"
         keystorePass="changeit"
           maxThreads="150"
                 port="8443"
             protocol="org.apache.coyote.http11.Http11NioProtocol"
               scheme="https"
               secure="true"
          sslProtocol="TLS"/>
  1. 创建证书时:使用主机名作为证书名称以及DNS名称。请参阅server.xml文件中的名称。

  2. 编辑iOS应用程序指向特定主机名(例如https://hostName",而不是" localhost"。

相关内容

最新更新