Skip to content

Password login fails with CERTIFICATE_VERIFY_FAILED: gsd.apple.com chains to Apple Root CA - G3 #339

Closed

Description

@JuiceKing710

Description

After #337 (the -80045 fix, tracked in #329), password login gets past the old error but then fails the TLS handshake:

Logging in...
Error: handshakeFailed(NIOSSL.BoringSSLError.sslError([Error: 268435581 error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED at .../swift-nio-ssl/Sources/CNIOBoringSSL/ssl/handshake.cc:288]))

Cause

gsd.apple.com (one of the hosts the login flow now talks to; I saw gsa.apple.com and gsd.apple.com in the request SNI via strace) serves a chain that ends at Apple Root CA - G3:

$ openssl s_client -connect gsd.apple.com:443 -servername gsd.apple.com -showcerts
 0 s:CN=gsd.apple.com, O=Apple Inc., ST=California, C=US
   i:CN=Apple Server Authentication CA 2, OU=Apple Certification Authority, O=Apple Inc., C=US
 1 s:CN=Apple Server Authentication CA 2, ...
   i:CN=Apple Root CA - G3, OU=Apple Certification Authority, O=Apple Inc., C=US
 2 s:CN=Apple Root CA - G3, ...   (self-signed)

gsa.apple.com still chains to the 2006 "Apple Root CA". Client.tlsConfiguration in Sources/XKit/HTTPClientProtocol/AsyncHTTPClient+HTTP.swift only adds that 2006 root to additionalTrustRoots, and Apple Root CA - G3 is not in Ubuntu's ca-certificates bundle, so verification of gsd.apple.com fails on Linux. (macOS trusts it in the system keychain, which is probably why this doesn't show up there.)

Fix

Add Apple Root CA - G3 to additionalTrustRoots:

-        tlsConfiguration.additionalTrustRoots = [.certificates([appleRootCA])]
+        // gsd.apple.com chains to Apple Root CA - G3 (not the 2006 Apple Root CA).
+        // swiftlint:disable:next force_try
+        let appleRootG3CA = try! NIOSSLCertificate(bytes: Array(appleRootG3PEM.utf8), format: .pem)
+        tlsConfiguration.additionalTrustRoots = [.certificates([appleRootCA, appleRootG3CA])]

plus a private let appleRootG3PEM = """ ... """ constant next to appleRootPEM. I took the certificate from https://www.apple.com/certificateauthority/AppleRootCA-G3.cer (fetched over a normally verified TLS connection). SHA-256 fingerprint:

63:34:3A:BF:B8:9A:6A:03:EB:B5:7E:9B:3F:5F:A7:BE:7C:4F:5C:75:6F:30:17:B3:A8:C4:88:C3:65:3E:91:79

openssl s_client -connect gsd.apple.com:443 -servername gsd.apple.com -CAfile AppleRootCA-G3.pem reports Verify return code: 0 (ok).

Verification

Built main at fae1981 (#337) with that change on Ubuntu 26.04, Swift 6.4.0, x86_64. Before: the handshake error above. After: login with a deliberately fake account reaches Apple and is rejected with Your account information was entered incorrectly. (-20101), i.e. the TLS handshake now succeeds. A real login with an existing Apple ID then succeeded and xtool auth status showed it as logged in.

Notes

  • I did not test the stock 1.21.0 AppImage on this path, because it failed earlier with -80045, so I can't say whether this is new with gsa: fix login using mismatched client-info #337 or was hidden behind the earlier failure.
  • Unrelated to this fix, if useful: the patch is small; happy to open a PR if you prefer that over the diff above.

Environment

  • Linux: Ubuntu 26.04 (x86_64)
  • xtool: built from main @ fae1981 (1.22.0 per --version)
  • Swift: 6.4.0
  • Login mode: password

Activity

  1. JuiceKing710 commented on Oct 13, 2026

    @JuiceKing710
    Author

    Follow-up: with this one-line trust-root change on top of #337, the whole flow now works end to end on Linux: password login, device registration, provisioning, signing and xtool install --usb of an ipa onto a real iPhone ("Successfully installed!"). One unrelated hiccup on the first install attempt: profile creation returned a 409 "There are no current IOS devices on this team matching the provided device IDs" right after the device had been added; an immediate retry succeeded, so that looks like a transient/eventual-consistency issue on Apple's side rather than anything in xtool.

  2. kabiroberai commented on Oct 14, 2026

    @kabiroberai
    Member

    Thanks for the investigation! This will be fixed by #340.

  3. added a commit that references this issue on Oct 14, 2026
    65bf3cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions