Hi I want to add certificate and its privatekey in https request, like this mentioned in this cURL `curl -L -i -X PUT –cert ./[device_cert].pem –key ./[device_cert_private_key].pem -H 'Content-Type: application/json' -H 'Content-Encoding: utf-8' -d '{"registrationId": "[registration_id]"}' https://global.azure-devices-provisioning.net/%5BID_Scope%5D/registrations/%5Bregistration_id%5D/register?api-version=2021-06-01
I recommend that you start by reading TLS for App Developers.
As to your specific question, it depends on what HTTP API you’re using. The most popular is URLSession
, and that supports mTLS via the authentication challenge mechanism. You can find general information about that in Handling an authentication challenge.
The specific challenge here is NSURLAuthenticationMethodClientCertificate
. To resolve that challenge you need a credential with containing a digital identity (SecIdentity
). You usually get that from the keychain using the SecItem API. If you start out with a PEM, you typically convert that to a PKCS#12 and then import it using SecPKCS12Import(…)
.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"