Release Notes
Announcements
keytool -importcert -trustcacerts -file <certificate file> -keystore <trust store> -storepass <password>
-file <certificate file>: SSL certificate or TLS certificate file MongoDB-CA.crt-keystore <trust store>: Specified keystore name-storepass <password> : Specified keystore password.trustStore and password as required to refer to correct keystore. You also need to replace the URI combination with the user password information that is used to access the database.System.setProperty("javax.net.ssl.trustStore", trustStore);System.setProperty("javax.net.ssl.trustStorePassword", password);import com.mongodb.MongoClientURI;import com.mongodb.MongoClientOptions;String uri = "mongodb://mongouser:password@10.x.x.1:27017/admin";MongoClientOptions opt = MongoClientOptions.builder().sslEnabled(true).sslInvalidHostNameAllowed(true).build();MongoClient client = new MongoClient(uri, options);
package mainimport ("context""crypto/tls""crypto/x509""io/ioutil""go.mongodb.org/mongo-driver/mongo""go.mongodb.org/mongo-driver/mongo/options")func main() {ca, err := ioutil.ReadFile("MongoDB-CA.crt")if err != nil {return}pool := x509.NewCertPool()ok := pool.AppendCertsFromPEM([]byte(ca))if !ok {return}tlsConfig := &tls.Config{RootCAs: pool,InsecureSkipVerify: true,}uri := "mongodb://mongouser:password@10.x.x.1:27017/admin?ssl=true"clientOpt := options.Client().ApplyURI(uri)clientOpt.SetTLSConfig(tlsConfig)client, err := mongo.Connect(context.TODO(), clientOpt)if err != nil {return}client.Disconnect(context.TODO())}
from pymongo import MongoClienturi = "mongodb://mongouser:password@10.x.x.1:27017/admin"client = MongoClient(uri,ssl=True,ssl_ca_certs='MongoDB-CA.crt',ssl_match_hostname=False)
피드백