apple / swift-nio-ssl

TLS Support for SwiftNIO, based on BoringSSL.
https://swiftpackageindex.com/apple/swift-nio-ssl/main/documentation/niossl
Apache License 2.0
385 stars 139 forks source link

Case-insensitive identity verification #463

Closed baarde closed 2 months ago

baarde commented 2 months ago

RFC 5280 states that while uppercase and lowercase letters are allowed in domain names, no significance is attached to the case, meaning the case should be ignored when comparing domain names.

Most certificates don't have any uppercase letter in their domain name. But some do.

SwiftNIO SSL converts the server hostname to lowercase but doesn't convert the certificate's CN or SAN. Therefore, the domain name comparison always fails when the certificate has uppercase letters in its domain name.

Steps to reproduce

Expected result

A parsing error invalid constant string is thrown (the server is not a valid HTTP server).

Actual result

NIOSSLExtraError.failedToValidateHostname: Couldn't find localhost in certificate from peer is thrown.

Lukasa commented 2 months ago

This is a great catch, thanks. Are you interested in backporting your fix from swift-certificates? We're not cutting over to it immediately so it'd be nice to fix it in both places.

baarde commented 2 months ago

Yes. Here's the PR #464.