我有一个在Trafik实例后面托管的tt-rss服务器。主机类似于ttrss.example.com,我像https://ttrss.example.com一样在网络上访问它。它在互联网上的任何地方都运行得很好。
当我试图提出这样的请求
AF
.request(
"\(url)/api",
method: .post,
parameters: ["user": user, "password": password],
encoding: JSONEncoding.default
)
.responseDecodable(of: SessionResponseModel.self) { response in
debugPrint("Response: \(response)")
}我遇到了一个错误
2022-09-29 21:24:36.652181-0400 ttc[89065:7539083] Task <808A492A-D131-448F-ADFD-4EE7158251D9>.<2> finished with error [-1022] Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLStringKey=http://ttrss.example.com:8889/api/, NSErrorFailingURLKey=http://ttrss.example.com:8889/api/, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <808A492A-D131-448F-ADFD-4EE7158251D9>.<2>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <808A492A-D131-448F-ADFD-4EE7158251D9>.<2>, NSUnderlyingError=0x600002b39e60 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}}正如你所看到的,沿着这条线,阿拉莫火修改了我的网址。顺便提一句,8889是我的tt服务器运行在Traefik后面的端口。
我的问题是:为什么阿拉莫火不只是使用我提供的网址.进一步解析url,但只是部分解析?
我不认为这是一个问题,无论是tt-rss或Traefik,因为这两件事是运行良好的每一个其他部分的互联网。在特拉菲克,我可能缺少了一些阿拉莫火需要的配置,但除此之外,我不确定我在这里做错了什么。
编辑:我不再这样做,这是阿拉莫火。我相信是Swift或iOS不正确地解决了这个网址(据我说)。
发布于 2022-10-01 06:42:01
如果读取错误,这是一个应用程序传输安全错误,这意味着系统无法根据默认ATS规则安全地连接。在您的情况下,这是因为您根本不使用https。您需要使用https进行连接,或者如果不能,则使用苹果文档中显示的方法为该域启用不安全的连接。
https://stackoverflow.com/questions/73903198
复制相似问题