AWS S3.NET SDK

I am using Unity3D and trying to use the S3.NET SDK. But keep getting below errors:

TlsException: Invalid certificate received from server. Error code: 0xffffffff80092012 Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () 

My javascript code is:

 function Start() { client = Amazon.AWSClientFactory.CreateAmazonS3Client(Conf.AWSAccessKey, Conf.AWSSecretKey); var response : ListBucketsResponse = client.ListBuckets(); } 

I searched all day and probably found a reason:

It turns out that Mono is installed without root certificates, so by default Mono refuses to trust any secure SSL services. The Mono Security FAQ has some troubleshooting tips. "

I tried the following methods:

  • Link

     mcs am1.cs mono am1.exe https://www.amazonaws.com 

    When I run the compiled am1.exe file, it gives me a lot of exception errors.

  • Use the mozroots.exe tool to download and install all Mozilla root certificates.

     C:\Program Files (x86)\Mono-2.6.7\lib\mono\1.0>mozroots --import --machine --sync 

    Although the output indicates that the certificates were successfully imported. But in Unity3D, it still asks for "Invalid certificate received from server"

I have been working on this all day and cannot solve the problem, I hope someone can help me.

+4
source share
3 answers

0x80092012 occurs when a certificate cannot be verified for revocation.

Starting with version 2.8, Mono will default to X509RevocationMode.NoCheck if the environment variable MONO_X509_REVOCATION_MODE is not set (in this case, it checks for CRLs inside certificate stores).

I do not know how the recent version of Unity3D belongs to Mono. However, you should be able to use ICertificatePolicy or ServicePointManager.ServerCertificateValidationCallback to work around this problem. Just ignore error code 0x80092012 if it comes from a certificate issued by Amazon.

+1
source
 public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy { public TrustAllCertificatePolicy() {} public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest req, int problem) { return true; } } 

Therefore, before establishing an HTTPS connection (via WebRequest, WebServices or another) to a remote server, simply call:

 System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); 

Enjoy

0
source

If you use ASP for mono, you need to download and install Mozilla root certificates using www-data user

 chown www-data /var/www/ sudo -u www-data mozroots --import --sync 
0
source

All Articles