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

Connection issue to Mongodb SSL using mono in mac

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Cannot Reproduce
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.1
    • Security
    • None
    • MongoDB 2.6.1, Mac Osx

    Description

      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.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: