SWIFT: server certificate does NOT include an ID which matches the server name

I'm working on MBP OSX Ventura 13.5.2 I'm working with Swift 5 (Xcode 15.2) I have a local httpd configured with vhosts. I create my local certs using mkcert.

When I visit the https://example site with Chrome the certificate is perfectly valid and there are no issues.

When I try and contact the same site using a DataCallBack function to the URL I get the error "server certificate does NOT include an ID which matches the server name"

In the log:

Connection 1: default TLS Trust evaluation failed(-9807)
Connection 1: TLS Trust encountered error 3:-9807
Connection 1: encountered error(3:-9807)

I should also mention, the url domain name I use from Chrome is the same url domain name I use from Swift.

Error -9807 is errSSLXCertChainInvalid, which means that the system wasn’t able to build a certificate chain from the leaf to a trusted root. How you handle that depends on the API you’re using and eventual deployment plan.

Let’s start with APIs. You wrote:

When I try and contact the same site using a DataCallBack function

That’s not an Apple API that I recognise. Are you using a third-party framework here? Or is this your code and it’s calling some Apple API, like URLSession?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

SWIFT: server certificate does NOT include an ID which matches the server name
 
 
Q