Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2486

SSL encryption with MongoClient using TLS 1.2

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Configuration
    • None
    • Environment:
      prod

      I am forcing the MongoClient to use SSL with TLS 1.2. Here is the code . I am getting the error: incompatible types when I am passing to the MongoClientOptions.Builder.

      Is there a better approach for enforcing TLS 1.2 for the client connection . I am using java driver 3.4.2 connecting to mongoDB 3.0.6.

        SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
          MongoClientOptions.Builder builder = MongoClientOptions.builder().socketFactory((SSLSocketFactory)sslContext.getSocketFactory()).build();
              MongoClientOptions sslOptions builder.sslEnabled(true).sslInvalidHostNameAllowed(true).build();
      
      java:87: error: incompatible types
              MongoClientOptions.Builder builder = MongoClientOptions.builder().socketFactory(sslContext.getSocketFactory()).build();
                                                                                                                                  ^
        required: Builder
        found:    MongoClientOptions
      1 error
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            tsantoshk Santosh Kumar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: