背景 完全なssl検証を有効にして、同じ方法でローカルでmongoを実行しようとしています。 Mongoは証明書が自己署名されていると不平を言っていますが、検証するためにルート証明書として扱うべきだと思うca.crtファイルを指定しています。それが合理的であれば、私のmongo configかcert生成が正しくないと思います。私は、次のdev envをmongo + sslで実行しています
#!/bin/sh
# Generate self signed root CA cert
openssl req -nodes -x509 -newkey rsa:2048 -keyout ca.key -out ca.crt -subj "/[email protected]"
# Generate server cert to be signed
openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr -subj "/[email protected]"
# Sign the server cert
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt
# Create server PEM file
cat server.key server.crt > server.pem
# Generate client cert to be signed
openssl req -nodes -newkey rsa:2048 -keyout client.key -out client.csr -subj "/[email protected]"
# Sign the client cert
openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAserial ca.srl -out client.crt
# Create client PEM file
cat client.key client.crt > client.pem
モンゴDBの設定 私はその後、(ドッカ内)で実行しているモンゴの設定を実行しているSSLのものを作成するには
SSLキー/本命/ PEM 以下の通りです。 (/ data/mongoは上に生成された場所です)。
をモンゴへの接続mongo --config config/location
経由
net:
port: 27017
ssl:
mode: requireSSL
CAFile: /data/mongo/ca.crt
PEMKeyFile: /data/mongo/server.pem
allowInvalidHostnames: true
setParameter:
enableLocalhostAuthBypass: true
と実行している私は、次のようにMongoのコマンドラインを使用してサーバーに接続しよう。
mongo --ssl --sslPEMKeyFile /data/mongo/client.pem --sslCAFile /data/mongo/ca.crt
そして
MongoDB shell version: 3.2.14
connecting to: test
2017-07-19T20:12:31.456+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60516 #1 (1 connection now open)
2017-07-19T20:12:31.461+0000 E NETWORK [conn1] SSL peer certificate validation failed: self signed certificate
2017-07-19T20:12:31.461+0000 I NETWORK [conn1] end connection 127.0.0.1:60516 (0 connections now open)
2017-07-19T20:12:31.461+0000 E NETWORK [thread1] SSL peer certificate validation failed: self signed certificate
2017-07-19T20:12:31.461+0000 E QUERY [thread1] Error: socket exception [CONNECT_ERROR] for SSL peer certificate validation failed: self signed certificate :
[email protected]/mongo/shell/mongo.js:229:14
@(connect):1:6
exception: connect failed
これはちょっと変です。 MongoDBのドキュメントでは、MongoDBが自己署名証明書のホスト名を検証しないことを示しています。* "[[自己署名証明書を使用する場合]]サーバIDの検証は行われません。マニュアルの[mongodとmongosのTLS/SSLの設定](https://docs.mongodb.com/manual/tutorial/configure-ssl/)を参照してください。 – jww
*** 'CN = www.example.com' ***はおそらく間違っています。ホスト名は常に* SAN *に入ります。 * CN *内に存在する場合は、* SAN *にも存在する必要があります(この場合は2回リストする必要があります)。詳細なルールと理由については、[証明機関との証明書署名要求の署名方法](http://stackoverflow.com/a/21340898/608639)および[opensslによる自己署名証明書の作成方法]( http://stackoverflow.com/q/10175812/608639)また、自己署名証明書を適切なトラストストアに配置する必要があります。 – jww
私はこれを行う方法を完全に理解しているとは思わない?それはsubj argsのそれぞれに入っていますか? – jimmiebtlr