My knowledge about SSL is very basic and I need to generate self-signed SSL certificates for a local server [server.local] so I can use it in a mobile app for SSL pinning.
How do I create a self-signed certificate, following the rules established by Apple below, via openssl x509?
- All TLS server certificates must comply with these new security requirements in iOS 13 and macOS 10.15; connections to TLS servers violating these new requirements will fail and may cause network failures, apps to fail, and websites to not load in Safari:
- Certificates and issuing CAs using RSA keys must use key sizes ≥2048 bits; RSA key sizes <2048 bits are no longer trusted
- Certificates, and issuing CAs, must use a hash algorithm from the SHA2 family in the signature algorithm; SHA1 signed certificates are no longer trusted for TLS
- Certificates must present the DNS name of the server in the
SubjectAltNameextension of the certificate; DNS names in theCommonNameof a certificate are no longer trusted - Certificates issued after July 1, 2019, as indicated in the NotBefore field of the certificate, must follow these guidelines:
- Certificates must contain an
extendedKeyUsage(EKU) extension containing theid-kp-serverAuthOID - Certificates must have a validity period of ≤825 days, as expressed in the NotBefore and NotAfter fields of the certificate.
- Certificates must contain an
I created the certificate via:
openssl genrsa -des3 -out myCA.key 2048
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 825 -out myCA.pem
After installing it on the server and device, when I try to use this inside iOS, I get error:
SSL hostname does not match name(s) in certificate,
Extended key usage does not match certificate usage, Root is not trusted`