-
Type:
Question
-
Resolution: Cannot Reproduce
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.6.1
-
Component/s: Security
-
None
-
Environment:MongoDB 2.6.1, Mac Osx
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
I have setup MongoDB SSL on my test machine on mac. now I am able to connect to mongo shell using ca file.
I have created a client certificate using same CA and now trying to connect to my application using that .pfx file on mac using mono. below is the code I am suing for connection to MongoDB.
mongoSettings.UseSsl = connectionInfo.EnableSSL; mongoSettings.SslSettings = new SslSettings(); mongoSettings.SslSettings.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Default; mongoSettings.SslSettings.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true; try { if (connectionInfo.VerifyClientCertificate) { certFile = DeadlineConfig.GetCertFilePath(); string password = DeadlineConfig.GetSSLPassword(); if (certFile == null || certFile == "") { certFile = connectionInfo.CertFile; password = connectionInfo.SSLPassword; } password = password.Replace("\n", String.Empty); password = password.Replace("\r", String.Empty); password = password.Replace("\t", String.Empty); password = password.Trim(); System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(certFile, password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet); mongoSettings.SslSettings.ClientCertificates = new List<System.Security.Cryptography.X509Certificates.X509Certificate>() { cert }; mongoSettings.SslSettings.ClientCertificateSelectionCallback = (sender, host, certificates, certificate, issuers) => mongoSettings.SslSettings.ClientCertificates.ToList()[0]; } }
It fails with error - Unable to connect to server : The authentication or decryption has failed.
Please anyone could look into this.