自己管理型MongoDBでのメンバーシップ認証に X.509 証明書を使用
MongoDB supports X.509 certificate authentication for use with a secure TLS/SSL connection. Sharded cluster members and replica set members can use X.509 certificates to verify their membership to the cluster or the replica set instead of using keyfiles. The membership authentication is an internal process.
注意
MongoDB は、TLS 1.1 + が利用可能なシステムで TLS 1.0暗号化のサポートを無効にします。
Enabling internal authentication also enables 自己管理型配置におけるロールベースのアクセス制御. Clients must authenticate as a user in order to connect and perform operations in the deployment.
See the 自己管理型配置でユーザーとロールを管理 tutorial for instructions on adding users to the deployment.
See the X.509 証明書を使用した自己管理型配置でのクライアントの認証 tutorial for instructions on using X.509 certificates for user authentication.
重要
TLS/SSL、PKI(公開鍵暗号基盤)証明書、特に X.509 証明書と証明機関の詳細な説明は、このドキュメントの範囲外になります。このチュートリアルでは、TLS/SSL に関する事前の知識と、有効な X.509 証明書にアクセスできることを前提としています。
メンバー X.509 証明書
注意
You must have valid X.509 certificates.
--tlsAllowInvalidCertificates
またはnet.tls.allowInvalidCertificates: true
を指定した場合、無効な証明書は TLS 接続を確立するには十分ですが、認証には不十分です。
Certificate Requirements
メンバー証明書を使用して、シャーディングされたクラスターまたはレプリカセットへのメンバーシップを検証します。メンバー証明書ファイルのパスは net.tls.clusterFile
オプションおよび net.tls.certificateKeyFile
オプションで構成されます。メンバーには次の構成要件があります。
クラスター ノードの設定では、認証に使用される属性の少なくとも 1 つに空でない値を指定する必要があります。デフォルトで MongoDB は次のものを受け入れます。
組織 (
O
)組織単位 (
OU
)ドメインコンポーネント (
DC
)
net.tls.clusterAuthX509.extensionValue
を設定することで、認証に使用する代替属性を指定できます。
クラスター ノード設定には同じ
net.tls.clusterAuthX509.attributes
を含み、一致する値を使用する必要があります。属性の順序は関係ありません。次の例えではO
とOU
を設定しますが、DC
は設定しません。net: tls: clusterAuthX509: attributes: O=MongoDB, OU=MongoDB Server
注意
enforceUserClusterSeparation
パラメータを無効にすると、次の動作が適用されます。
構成ファイルで
clusterAuthMode
がkeyFile
の場合、O/OU/DC
チェックは無効になります。 これにより、メンバー証明書を持つクライアントは、$external
データベースに保存されているユーザーとして認証できるようになります。構成ファイルで
clusterAuthMode
がkeyFile
でない場合、サーバーは起動しません。
enforceUserClusterSeparation
パラメータをfalse
に設定すると、サーバーは、アプリケーションが認証に使用するクライアント証明書と、特権アクセス権を持つクラスター内証明書を区別しません。 これは、 clusterAuthMode
がkeyFile
である場合、効果はありません。 ただし、 clusterAuthMode
がx509
の場合、許可されたスキームを使用するユーザー証明書はクラスター証明書と複合化され、特権アクセスが付与されます。
次の操作を行うと、既存の証明書に内部特権が付与されます。
このパラメーターで許可された名前を持つユーザーを作成します。
enforceUserClusterSeparation
パラメータをfalse
に設定します。clusterAuthMode
をx509
に設定します。
enforceUserClusterSeparation
フラグによって作成が許可された昇格特権を持つユーザーを削除したことを検証せずに、 keyFile
からx509
にアップグレードすることはできません。
enforceUserClusterSeparation
パラメータをfalse
に設定するには、起動時に次のコマンドを実行します。
mongod --setParameter enforceUserClusterSeparation=false
証明書には次の要件があります。
単一の認証局(CA)が、シャーディングされたクラスターまたはレプリカセットのノードに対してすべての X.509 証明書を発行する必要があります。
サブジェクト代替名 (
SAN
) エントリの少なくとも 1 つは、他のクラスター ノードが使用するサーバー ホスト名と一致する必要があります。SAN
を比較する際に、MongoDB は DNS 名または IP アドレスのいずれかを比較できます。subjectAltName
を指定しない場合、MongoDB は代わりに共通名(CN)を比較します。 ただし、CN のこの使用は RFC に従って非推奨です。2818certificateKeyFile
として使用される証明書にextendedKeyUsage
が含まれている場合、値にはclientAuth
(「TLS Web クライアント認証」)とserverAuth
(「TLS Web サーバー認証」)の両方を含める必要があります。extendedKeyUsage = clientAuth, serverAuth clusterFile
として使用される証明書にextendedKeyUsage
が含まれている場合、値にはclientAuth
が含まれている必要があります。extendedKeyUsage = clientAuth
Configure Replica Set/Sharded Cluster
Outside of rolling upgrade procedures, every component of a replica set or sharded cluster should use the same
--clusterAuthMode
setting to ensure it can securely connect to all
other components in the deployment.
For replica set deployments, this includes all mongod
members of the replica set.
For sharded cluster deployments, this includes all mongod
or mongos
instances.
注意
mongod
と mongos
は、デフォルトで localhost にバインドされます。配置のノードが異なるホスト上で実行されている場合、またはリモート クライアントを配置に接続する場合は、--bind_ip
または net.bindIp
を指定する必要があります。
Use Command-line Options (tls
)
注意
The procedures in this section use the tls
settings/option. For
procedures using the deprecated ssl
aliases, see
Use Command-line Options (ssl
).
MongoDB では常に TLS 1.0 以降をサポートしているため、 tls
の設定/オプションはssl
オプションと同じ機能を提供します。
mongod --replSet <name> --tlsMode requireTLS --clusterAuthMode x509 --tlsClusterFile <path to membership certificate and key PEM file> --tlsCertificateKeyFile <path to TLS/SSL certificate and key file> --tlsCAFile <path to root CA file> --bind_ip localhost,<hostname(s)|ip address(es)>
重要
X.509認証を使用するには、--tlsCertificateSelector
または --net.tls.certificateSelector
を使用している場合を除き、--tlsCAFile
または net.tls.CAFile
を指定する必要があります。
Include any additional options, TLS/SSL or otherwise, that are required for your specific configuration. For
security: clusterAuthMode: x509 net: tls: mode: requireTLS certificateKeyFile: <path to its TLS/SSL certificate and key file> CAFile: <path to root CA PEM file to verify received certificate> clusterFile: <path to its certificate key file for membership authentication> bindIp: localhost,<hostname(s)|ip address(es)>
重要
X.509認証を使用するには、--tlsCertificateSelector
または --net.tls.certificateSelector
を使用している場合を除き、--tlsCAFile
または net.tls.CAFile
を指定する必要があります。
Include any additional options, TLS/SSL or otherwise, that are required for your specific configuration.
For more information, see TLS/SSL の mongod
と mongos
を構成します。
Use Command-line Options (ssl
)
注意
The procedures in this section use the deprecated ssl
settings/option.
For procedures that use tls
aliases, see Use Command-line Options (tls
).
MongoDB では常に TLS 1.0 以降をサポートしているため、 tls
の設定/オプションはssl
オプションと同じ機能を提供します。
To specify the X.509 certificate for internal cluster member
authentication, append the additional TLS/SSL options
--clusterAuthMode
and --sslClusterFile
, as in the
following example for a member of a replica set:
mongod --replSet <name> --sslMode requireSSL --clusterAuthMode x509 --sslClusterFile <path to membership certificate and key PEM file> --sslPEMKeyFile <path to TLS/SSL certificate and key PEM file> --sslCAFile <path to root CA PEM file> --bind_ip localhost,<hostname(s)|ip address(es)>
重要
X.509認証を使用するには、--tlsCertificateSelector
または --net.tls.certificateSelector
を使用している場合を除き、--tlsCAFile
または net.tls.CAFile
を指定する必要があります。
Include any additional options, TLS/SSL or otherwise, that are required for your specific configuration.
security: clusterAuthMode: x509 net: ssl: mode: requireSSL PEMKeyFile: <path to TLS/SSL certificate and key PEM file> CAFile: <path to root CA PEM file> clusterFile: <path to X.509 membership certificate and key PEM file> bindIp: localhost,<hostname(s)|ip address(es)>
重要
X.509認証を使用するには、--tlsCertificateSelector
または --net.tls.certificateSelector
を使用している場合を除き、--tlsCAFile
または net.tls.CAFile
を指定する必要があります。
Include any additional options, TLS/SSL or otherwise, that are required for your specific configuration.
For more information, see TLS/SSL の mongod
と mongos
を構成します。
詳細情報
鍵ファイルによる内部認証から X.509 内部認証にアップグレードするには、「 自己管理型MongoDB を鍵ファイル認証から X. 認証にアップグレードする509 」を参照してください。
To perform a rolling update of the certificates to new certificates
with different DN
, see
自己管理型クラスターで clusterAuthX509 属性を使用せずに X.509 証明書をローテーション.