「Samba AD DCでLDAP over SSL(LDAPS)を構成する」の版間の差分
(同じ利用者による、間の2版が非表示) | |||
78行目: | 78行目: | ||
* Sambaを再起動する。 | * Sambaを再起動する。 | ||
= | = 信頼できる証明書を使用する = | ||
* | * キーと証明書を保存するディレクトリに移動します | ||
# cd /usr/local/samba/private/tls/ | # cd /usr/local/samba/private/tls/ | ||
* | * 2048ビットのサーバーキーを作成します | ||
# openssl genrsa -out myKey.pem 2048 | # openssl genrsa -out myKey.pem 2048 | ||
* | * 証明書要求(CSR)を生成します。 いくつかの質問があります。 最も重要なのは、証明書を生成するDCのFQDN( "hostname -f")を "Common Name"に入力することです。 | ||
# openssl req -new -key myKey.pem -out myCSR.pem | # openssl req -new -key myKey.pem -out myCSR.pem | ||
104行目: | 104行目: | ||
Email Address []:demo@example.com | Email Address []:demo@example.com | ||
* | * CSRを使用して、CAから信頼できる証明書を取得します。 プロセスの詳細については、ベンダーのページを確認してください。 | ||
* | * 信頼できる証明書を受け取った場合は、その証明書をサーバーキー(たとえば、myCert.pemという名前)を持つディレクトリーに保管します。 | ||
* | * CAが中間証明書を必要とする場合は、他のファイルと同じディレクトリに格納します(myIntermediate.pemなど)。 | ||
* | * smb.confに次のパラメータを追加します。 | ||
tls enabled = yes | tls enabled = yes | ||
tls keyfile = tls/myKey.pem | tls keyfile = tls/myKey.pem | ||
116行目: | 116行目: | ||
tls cafile = tls/myIntermediate .pem # if not required, set empty | tls cafile = tls/myIntermediate .pem # if not required, set empty | ||
* | * Sambaを再起動する | ||
= 証明書の詳細を表示する = | |||
= | |||
# openssl x509 -in /usr/local/samba/private/tls/myCert.pem -noout -text | # openssl x509 -in /usr/local/samba/private/tls/myCert.pem -noout -text | ||
154行目: | 149行目: | ||
.....{removed to keep this example output shorter}..... | .....{removed to keep this example output shorter}..... | ||
= 証明書の確認 = | |||
== ローカル == | |||
= | |||
# openssl verify /usr/local/samba/private/tls/myCert.pem | # openssl verify /usr/local/samba/private/tls/myCert.pem | ||
167行目: | 158行目: | ||
OK | OK | ||
smb.confでCAファイルを使用している場合は、代わりに次のコマンドを使用します。: | |||
# openssl verify /usr/local/samba/private/tls/myCert.pem -CApath /path/to/ca-file.pem | # openssl verify /usr/local/samba/private/tls/myCert.pem -CApath /path/to/ca-file.pem | ||
173行目: | 164行目: | ||
== | == TCP経由のリモート == | ||
# openssl s_client -showcerts -connect dc1.samdom.example.com:636 | # openssl s_client -showcerts -connect dc1.samdom.example.com:636 | ||
219行目: | 210行目: | ||
--- | --- | ||
'' | '' [Ctrl] + [C]を押すとs_clientを終了できます。 '' | ||
smb.confでCAファイルを使用している場合は、代わりに次のコマンドを使用します: | |||
# openssl s_client -showcerts -connect localhost:636 -CApath /path/to/ca-file.pem | # openssl s_client -showcerts -connect localhost:636 -CApath /path/to/ca-file.pem |
2018年9月26日 (水) 09:55時点における最新版
はじめに
Active Directoryは、LDAP(Lightweight Directory Access Protocol)を読み取りおよび書き込みアクセスに使用します。 デフォルトでは、LDAP接続は暗号化されていません。 LDAPトラフィックを保護するには、SSL / TLSを使用できます。 このドキュメントでは、Sambaに証明書をインストールすることにより、LDAP over SSL(LDAPS)を有効にする方法について説明します。
一般情報
- TLSを使うには、Sambaを„--enable-gnutls“でコンパイルする必要があります。確認するには、次のコマンドを使用してください:
# smbd -b | grep "ENABLE_GNUTLS" ENABLE_GNUTLS
- 秘密鍵はパスフレーズなしでアクセスできる必要があります。つまり、暗号化しないでください!
- sambaが使用するファイルは、PEM形式(Base64エンコードDER)でなければなりません。内容は、"-----BEGIN CERTIFICATE-----" と "-----END CERTIFICATE-----"で、囲まれています。
- 中間証明書を使用する場合は、サーバー証明書の後にcert.pemファイルに追加する必要があります。
LDAPSの重要なsmb.confパラメータ
LDAPSはさまざまなsmb.confパラメータによって制御され、すべてが "tls"で始まります。 詳細については、マニュアルページを参照してください。
"tls *"パラメータは、smb.confの "[global]"セクションで設定します。 変更が終わったら、Sambaを再起動する必要があります。
Sambaで自動生成された自己署名証明書を使用する(デフォルト)
最初の起動時に、Sambaは秘密鍵、自己署名証明書、およびCA証明書を作成します。
- /usr/local/samba/private/tls/ca.pem
- /usr/local/samba/private/tls/cert.pem
- /usr/local/samba/private/tls/key.pem
証明書は作成後700日間有効です(証明書の自動作成時に使用される有効期間は "source4/lib/tls/tlscert.c"にハードコードされています)。
デフォルトでは、TLSが有効( "tls enabled = yes")の場合、上記のファイルが使用され、次のsmb.confパラメータに対応します。
tls enabled = yes tls keyfile = tls/key.pem tls certfile = tls/cert.pem tls cafile = tls/ca.pem
独自の自己署名証明書を使用する
- キーと証明書を保存するディレクトリに移動します
# cd /usr/local/samba/private/tls/
- 1年間有効な秘密鍵(2048ビット)と自己署名証明書を作成します。 いくつかの質問があります。 "Common Name"に証明書を生成するDCのFQDN( "hostname -f")を入力することは非常に重要です!
# openssl req -newkey rsa:2048 -keyout myKey.pem -nodes -x509 -days 365 -out myCert.pem Generating a 2048 bit RSA private key ......+++ ..................+++ writing new private key to 'myKey.pem' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:DE State or Province Name (full name) []:My State Locality Name (eg, city) [Default City]:My City Organization Name (eg, company) [Default Company Ltd]:My Company Organizational Unit Name (eg, section) []:My Department Common Name (eg, your name or your server's hostname) []:DC1.samdom.example.com Email Address []:demo@example.com
- 秘密鍵のアクセス権を制限する
# chmod 600 myKey.pem
- smb.confに以下を追加してください
tls enabled = yes tls keyfile = tls/myKey.pem tls certfile = tls/myCert.pem tls cafile =
- Sambaを再起動する。
信頼できる証明書を使用する
- キーと証明書を保存するディレクトリに移動します
# cd /usr/local/samba/private/tls/
- 2048ビットのサーバーキーを作成します
# openssl genrsa -out myKey.pem 2048
- 証明書要求(CSR)を生成します。 いくつかの質問があります。 最も重要なのは、証明書を生成するDCのFQDN( "hostname -f")を "Common Name"に入力することです。
# openssl req -new -key myKey.pem -out myCSR.pem You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:DE State or Province Name (full name) []:My State Locality Name (eg, city) [Default City]:My City Organization Name (eg, company) [Default Company Ltd]:My Company Organizational Unit Name (eg, section) []:My Department Common Name (eg, your name or your server's hostname) []:DC1.samdom.example.com Email Address []:demo@example.com
- CSRを使用して、CAから信頼できる証明書を取得します。 プロセスの詳細については、ベンダーのページを確認してください。
- 信頼できる証明書を受け取った場合は、その証明書をサーバーキー(たとえば、myCert.pemという名前)を持つディレクトリーに保管します。
- CAが中間証明書を必要とする場合は、他のファイルと同じディレクトリに格納します(myIntermediate.pemなど)。
- smb.confに次のパラメータを追加します。
tls enabled = yes tls keyfile = tls/myKey.pem tls certfile = tls/myCert.pem tls cafile = tls/myIntermediate .pem # if not required, set empty
- Sambaを再起動する
証明書の詳細を表示する
# openssl x509 -in /usr/local/samba/private/tls/myCert.pem -noout -text Certificate: Data: Version: 3 (0x2) Serial Number: d7:16:0c:a9:2e:ce:6f:a6 Signature Algorithm: sha1WithRSAEncryption Issuer: C=DE, ST=My State, L=My City, O=My Company, OU=My Section, CN=DC1.samdom.example.com/emailAddress=demo@example.com Validity Not Before: Jun 22 06:44:35 2013 GMT Not After : Jun 22 06:44:35 2014 GMT Subject: C=DE, ST=My State, L=My City, O=My Company, OU=My Section, CN=DC1.samdom.example.com/emailAddress=demo@example.com Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: .....{removed to keep this example output shorter}..... Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Key Identifier: D3:CC:57:AD:2E:03:AC:EE:F9:1F:88:C7:96:A3:79:23:1E:1A:7E:45 X509v3 Authority Key Identifier: keyid:D3:CC:57:AD:2E:03:AC:EE:F9:1F:88:C7:96:A3:79:23:1E:1A:7E:45 X509v3 Basic Constraints: CA:TRUE Signature Algorithm: sha1WithRSAEncryption .....{removed to keep this example output shorter}.....
証明書の確認
ローカル
# openssl verify /usr/local/samba/private/tls/myCert.pem myCert.pem: C = DE, ST = My State, L = My City, O = My Company, OU = My Section, CN = DC1.samdom.example.com, emailAddress = demo@example.com error 18 at 0 depth lookup:self signed certificate OK
smb.confでCAファイルを使用している場合は、代わりに次のコマンドを使用します。:
# openssl verify /usr/local/samba/private/tls/myCert.pem -CApath /path/to/ca-file.pem
TCP経由のリモート
# openssl s_client -showcerts -connect dc1.samdom.example.com:636 CONNECTED(00000003) depth=0 C = DE, ST = My State, L = My City, O = My Company, OU = My Section, CN = DC1.samdom.example.com, emailAddress = demo@example.com verify error:num=18:self signed certificate verify return:1 depth=0 C = DE, ST = My State, L = My City, O = My Company, OU = My Section, CN = DC1.samdom.example.com, emailAddress = demo@example.com verify return:1 --- Certificate chain 0 s:/C=DE/ST=My State/L=My City/O=My Company/OU=My Section/CN=DC1.samdom.example.com/emailAddress=demo@example.com i:/C=DE/ST=My State/L=My City/O=My Company/OU=My Section/CN=DC1.samdom.example.com/emailAddress=demo@example.com -----BEGIN CERTIFICATE----- .....{removed to keep this example output shorter}..... -----END CERTIFICATE----- --- Server certificate subject=/C=DE/ST=My State/L=My City/O=My Company/OU=My Section/CN=DC1.samdom.example.com/emailAddress=demo@example.com issuer=/C=DE/ST=My State/L=My City/O=My Company/OU=My Section/CN=DC1.samdom.example.com/emailAddress=demo@example.com --- No client certificate CA names sent --- SSL handshake has read 1870 bytes and written 322 bytes --- New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA Server public key is 2048 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE SSL-Session: Protocol : TLSv1 Cipher : DHE-RSA-AES256-SHA Session-ID: 7B522F38E50A807426CBB438841A40360B8A32C2A6FA74B1705D2978E7100E9A Session-ID-ctx: Master-Key: D65E7EC785151B6DDA2CAB40320A16DADB5A24019B23C533738B43EA36DBC4E766BE16C292E35976BB6CD09B1C537D21 Key-Arg : None Krb5 Principal: None PSK identity: None PSK identity hint: None Start Time: 1371887189 Timeout : 300 (sec) Verify return code: 18 (self signed certificate) ---
[Ctrl] + [C]を押すとs_clientを終了できます。
smb.confでCAファイルを使用している場合は、代わりに次のコマンドを使用します:
# openssl s_client -showcerts -connect localhost:636 -CApath /path/to/ca-file.pem