For some time now (at least since the first release of Unity 5 and still on Unity 5.1.0f3), Mono’s WebRequest throws an exception when parsing the X509 certificate chain for my website. Here’s what Xcode’s error log/console says while I’m running my project on iOS:
—8<—
ERROR building certificate chain: System.ArgumentException:
certificate ---> System.Security.Cryptography.CryptographicException:
Unsupported hash algorithm: 1.2.840.113549.1.1.12
at Mono.Security.X509.X509Certificate.VerifySignature
(System.Security.Cryptography.RSA rsa) [0x00000] in <filename
unknown>:0
at Mono.Security.X509.X509Certificate.VerifySignature
(System.Security.Cryptography.AsymmetricAlgorithm aa) [0x00000] in
<filename unknown>:0
at System.Security.Cryptography.X509Certificates.X509Chain.IsSignedWith
(System.Security.Cryptography.X509Certificates.X509Certificate2
signed, System.Security.Cryptography.AsymmetricAlgorithm pubkey)
[0x00000] in <filename unknown>:0
at System.Security.Cryptography.X509Certificates.X509Chain.Process
(Int32 n) [0x00000] in <filename unknown>:0
at System.Security.Cryptography.X509Certificates.X509Chain.ValidateChain
(X509ChainStatusFlags flag) [0x00000] in <filename unknown>:0
at System.Security.Cryptography.X509Certificates.X509Chain.Build
(System.Security.Cryptography.X509Certificates.X509Certificate2
certificate) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Security.Cryptography.X509Certificates.X509Chain.Build
(System.Security.Cryptography.X509Certificates.X509Certificate2
certificate) [0x00000] in <filename unknown>:0
at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain
(Mono.Security.X509.X509CertificateCollection certs) [0x00000] in
<filename unknown>:0
Please, report this problem to the Mono team
—>8—
1.2.840.113549.1.1.12 is SHA-384, but my certificate only signs with SHA-256 (1.2.840.113549.1.1.11). Here’s OpenSSL’s output when parsing my certificate chain:
—8<—
% openssl x509 -in cert.crt -noout -text
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
c5:da:90:6f:a8:33:4d:79:76:ac:b6:a1:c9:52:45:d1
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA
Limited, CN=COMODO RSA Domain Validation Secure Server CA
Validity
Not Before: Apr 9 00:00:00 2015 GMT
Not After : Apr 8 23:59:59 2016 GMT
Subject: OU=Domain Control Validated, OU=PositiveSSL,
CN=www.dolphingame-online.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:c5:4f:0f:73:69:57:92:79:54:9d:18:28:e5:e2:
0a:53:71:f9:64:89:eb:44:f9:a9:48:c5:55:7b:0d:
ad:ba:cb:ae:39:37:64:00:78:af:e6:cf:be:42:24:
f8:50:36:de:ce:86:e3:89:61:91:ba:4f:e1:c1:01:
6c:f8:86:c5:d2:1a:5b:79:4e:7b:af:29:25:0c:d5:
47:32:ab:5d:91:8b:4b:36:2c:a1:a5:b2:05:e4:09:
8c:9a:4e:44:10:5f:48:5a:fe:6a:80:fc:97:b4:ef:
a6:aa:2f:cf:66:38:3d:10:39:d3:29:cc:a9:71:e6:
e8:4e:48:d2:74:7c:ff:69:8b:9f:27:36:7d:ac:df:
70:51:ba:42:50:0b:fe:75:c1:04:d0:86:69:47:f6:
db:e4:14:68:b0:db:d8:09:79:df:52:1a:51:f9:e9:
d9:fc:03:2b:02:1d:3e:68:b5:df:6c:e2:b7:0d:e3:
be:c9:67:a0:0b:c1:ad:5c:9a:de:ca:4e:62:e6:fa:
67:8e:64:75:bb:6e:03:01:bd:4b:ac:63:40:f5:27:
76:bd:b5:ec:57:50:31:7c:bb:ad:02:20:3c:98:da:
96:83:3e:96:16:61:18:c0:14:05:bb:f8:66:09:c7:
10:a3:01:0a:d4:42:b5:20:eb:e5:d7:90:bb:97:99:
47:87
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Authority Key Identifier:
keyid:90:AF:6A:3A:94:5A:0B:smile:8:90:EA:12:56:73:smile:F:43:B4:3A:28:smile:A:E7
X509v3 Subject Key Identifier:
59:59:61:24:4B:93:97:55:2B:0A:smile:F:97:FC:F7:58:C0:55:0B:63:58
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Basic Constraints: critical
CA:FALSE
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Certificate Policies:
Policy: 1.3.6.1.4.1.6449.1.2.2.7
CPS: https://secure.comodo.com/CPS
Policy: 2.23.140.1.2.1
X509v3 CRL Distribution Points:
Full Name:
URI:http://crl.comodoca.com/COMODORSADomainValidationSecureServerCA.crl
Authority Information Access:
CA Issuers -
URI:http://crt.comodoca.com/COMODORSADomainValidationSecureServerCA.crt
OCSP - URI:http://ocsp.comodoca.com
X509v3 Subject Alternative Name:
DNS:www.dolphingame-online.com, DNS:dolphingame-online.com
Signature Algorithm: sha256WithRSAEncryption
0a:ed:ed:af:12:4f:6f:50:c2:fd:89:09:9c:be:89:83:3f:95:
ec:ac:4e:c9:e9:2f:f5:57:c5:91:37:ca:ba:27:01:4e:d0:c2:
13:11:5b:3d:df:38:b8:f5:08:9e:58:38:f8:8e:6d:1f:0b:f2:
69:1b:45:c4:1e:c7:fc:08:0d:26:13:28:23:d0:d4:07:d1:eb:
0f:c5:f9:a5:4f:8f:12:60:34:0c:ed:d9:86:88:ce:7e:03:f3:
09:59:65:76:2a:f2:b2:fe:f5:93:82:16:9c:6b:5e:18:cd:05:
0e:bf:78:1c:2c:7c:63:c9:a8:64:38:24:70:21:de:00:2f:ad:
4f:12:b8:c7:8b:40:e1:65:22:d3:c3:7a:21:6b:0a:02:7d:3a:
0b:d3:ff:f3:07:7a:a6:60:8f:62:13:95:ea:ab:44:e1:78:b5:
9a:83:d1:cd:9e:d2:36:ed:19:fe:db:26:66:c5:11:d1:f4:51:
d7:8c:7e:f5:45:02:dc:70:0b:fd:20:af:d5:ec:43:a8:c2:ab:
db:68:60:39:a7:0f:1a:f8:8d:76:24:c6:26:86:e7:d4:b1:c5:
45:13:b4:b1:d6:87:7d:3e:0d:e2:71:0b:db:96:06:39:80:79:
df:13:b0:3e:fe:42:09:52:dc:1c:ef:b4:dd:43:9b:43:70:c5:
18:2e:ce:a6
—>8—
Unity’s Mono seems to think that my certificates use SHA-384, but they’re only using SHA-256. I only see this problem on iOS builds. Has anyone else seen this, too?
I’ve attached a ZIP file containing a project that’ll reproduce this problem. Keep an eye on Xcode’s console output when you run it. The ZIP also contains my certificate both encoded (.crt) and decoded (.txt).
Thanks!
2193481–145554–ios-https-problem.zip (1.57 MB)