简体   繁体   English

swift 添加 ssl 证书到 URLRequest

[英]swift add ssl certificate to URLRequest

I'm trying to control my Phillips hue lights from my app.我正在尝试通过我的应用程序控制我的 Phillips hue 灯。 Anyway they have an Api where we can control all of that.无论如何,他们有一个 Api,我们可以控制所有这些。 The issue is that on the software Postman (to test) they say to disable "SSL Certificate Verification".问题是在软件 Postman(测试)上,他们说要禁用“SSL 证书验证”。 When I try to call with URLRequest in my app the same url which is: "https://<ip_address_of_Hue_bridge>/clip/v2/resource/device" well, I get this error:当我尝试在我的应用程序中使用 URLRequest 调用相同的 url 时:“https://<ip_address_of_Hue_bridge>/clip/v2/resource/device” 好吧,我收到此错误:

Domain=kCFErrorDomainCFNetwork Code=-1202 NSLocalizedDescription=The certificate for this server is invalid. Domain=kCFErrorDomainCFNetwork Code=-1202 NSLocalizedDescription=此服务器的证书无效。 You might be connecting to a server that is pretending to be “<ip_address_of_Hue_bridge>” which could put your confidential information at risk.您可能正在连接到伪装成“<ip_address_of_Hue_bridge>”的服务器,这可能会使您的机密信息面临风险。

On the the Phillips Hue Developer portal they gave me something that look like the.cert certificate, but I don't know how to use it with Xcode.在 Phillips Hue 开发者门户网站上,他们给了我一些看起来像 .cert 证书的东西,但我不知道如何将它与 Xcode 一起使用。

I think that the better way for you is to ignore the SSL certificate of the Hue.我认为对您来说更好的方法是忽略 Hue 的 SSL 证书。 Give a look here.在这里看看。

https://stackoverflow.com/a/59484010/12277616 https://stackoverflow.com/a/59484010/12277616

I strongly suggest you to not disable SSL connection in Xcode.我强烈建议您不要禁用 Xcode 中的 SSL 连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM