首页 > 解决方案 > Swift 的 SSL 连接错误

问题描述

我对这个我无法弄清楚的新错误感到沮丧。

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9800)
HTTP load failed (error code: -1200 [3:-9800])
Optional("An SSL error has occurred and a secure connection to the server cannot be made.")

以下是 info.plist

<key>NSAppTransportSecurity</key>

我在tomcat中配置了godaddy ssl,并且只允许在httpd中使用tls1.2+。我不明白为什么会收到此错误。请帮助我找出这个问题并理解为什么会发生这种情况。

当我这样做时nscurl --ats-diagnostics https://myserver:port#,我得到

---
TLSv1.3 with PFS disabled and insecure HTTP allowed
2018-05-14 23:15:07.512 nscurl[36044:8746632] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9800)
Result : FAIL
---

如果我弄清楚这一点,我认为其他一切都会奏效。如果您对此有所了解,请帮助我。

我不想添加任意负载。我对此没有正当理由,但许多帖子说这是一个临时解决方案,对安全性有不良影响。

如果需要更多信息,请发表评论。感谢您的时间和帮助。


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>SOMETHING</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb1787966001498993</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>1787966001498993</string>
    <key>FacebookDisplayName</key>
    <string>MathMatch</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <key>NSPhotoLibraryUsageDescription</key>
    <string></string>
    <key>UIAppFonts</key>
    <array>
        <string>Brandon_bld.otf</string>
        <string>NotoSans-Regular.ttf</string>
        <string>DINPro_Regular.ttf</string>
    </array>
    <key>UIBackgroundModes</key>
    <array>
        <string>remote-notification</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true/>
    <key>UIStatusBarHidden</key>
    <true/>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

标签: swiftsslhttpserror-handling

解决方案


推荐阅读