NIOTransportServices TLS verify block prints "Trust failed" to stdout
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 73/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- swift
- Domain
- backend, networking
Research direction
Start with Sources/AsyncHTTPClient/NIOTransportServices/TLSConfiguration.swift at the linked verify block and trace how the background activity logger is made available when TLS options are created. Confirm the behavior on macOS with NIOTransportServices using a certificate verification failure; done when the failure reason is no longer written to stdout and remains available through the logger.
Written by the indexing model from the issue text.
Description
Description
On Darwin with NIOTransportServices, when certificate verification fails, the verify block installed by TLSConfiguration.getNWProtocolTLSOptions writes the failure to standard output:
The verify block was added in #350 (for #292) and is installed whenever certificateVerification != .fullVerification || trustRoots != nil. Because TLSConfiguration.makeClientConfiguration() sets trustRoots to .default, this also happens with the default client configuration.
For a command-line tool that prints machine-readable output (for example JSON) on stdout, the extra line corrupts the output.
Steps to reproduce
- On macOS, use
HTTPClient(eventLoopGroupProvider: .singleton)with the default configuration. - Send a request to a host whose certificate fails verification (for example
https://wrong.host.badssl.com). - Standard output contains
Trust failed: “*.badssl.com” certificate name does not match input.
Expected behavior
The library does not write to stdout.
The message carries the specific reason for the failure (expired, name mismatch, untrusted), which the NWTLSError the request fails with does not include. So rather than dropping it, it could go to the background activity logger (for example at debug level), which is already available where the TLS options are created.
Workaround
Setting tlsConfiguration.trustRoots = nil (with .fullVerification) avoids installing the verify block, so Network.framework evaluates trust itself and nothing is printed.
Environment
- async-http-client 1.36.0; the print is also present on main (6b7549b)
- macOS, NIOTransportServices
- Dominant language
- Swift
- Stars
- 1.1k
- Forks
- 159
- Avg merge
- 18h 43m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from swift-server/async-http-client
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
swift-server/async-http-client#946 · 2 comments ·
-
RequestBag keeps the request body after an early response with status >= 300Possibly taken @beshkenadze claimed this 28 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
HTTP/2 stream stays half-closed after an early response with status >= 300Possibly taken @beshkenadze claimed this 28 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Transaction keeps the request body after an early response with status >= 300Possibly taken @beshkenadze claimed this 28 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 22/100
All issues in swift-server/async-http-client
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Ranchero-Software/NetNewsWire#5572 ·
Maintainers usually reply within 11 days
-
api beginner story
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NCSU-App-Development-Club/ios_fall_26#86 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
yetanotherbrowser/yab#1008 ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 90/100