Unity(Mono)关于Https的一个坑

使用HttpWebRequest写的底层网络模块,证书部分全部返回True,调用微信公众号(小程序)二维码,以及小程序二维码,报错如下:

System.Net.WebException: Error: TrustFailure (The authentication or decryption has failed.) ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a
at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) [0x00037] in :0
at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (System.IAsyncResult ar, System.Boolean ignoreEmpty) [0x00000] in :0
at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (System.IAsyncResult result) [0x00071] in :0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (System.IAsyncResult result) [0x00032] in :0
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (System.IAsyncResult asyncResult) [0x0000c] in :0
--- End of inner exception stack trace ---

解决方案:

CMD 中 D:\Program Files\Unity_2017_3_1_f1\Editor\Data\MonoBleedingEdge\lib\mono\4.5\mozroots.exe --import --sync

Unity(Mono)关于Https的一个坑_第1张图片

对应路径自己改成自己的,把证书导入,就可以了...,老版本不成功的可能要替换mozroots的版本

为什么Windows下没问题:好像是因为Windows中自带证书...

Mono下的原因参考如下:

原因参考:https://www.mono-project.com/docs/faq/security/

 

你可能感兴趣的:(unity3d技术日志)