Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14256

Connection issue to Mongodb SSL using mono in mac

    • Type: Icon: Question Question
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.1
    • Component/s: Security
    • Labels:
      None
    • Environment:
      MongoDB 2.6.1, Mac Osx

      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.

        1. Vibhu_key.ppk
          1 kB
        2. vibhu.crt
          1 kB
        3. vibhu.key
          0.9 kB
        4. vibhu.pfx
          2 kB

            Assignee:
            ramon.fernandez@mongodb.com Ramon Fernandez Marina
            Reporter:
            vibhu.kasrija Vibhu Kasrija
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: