Table of Contents
現在に至るまで、ACLのような、いくつかの高度な機能を含む、 OpenLDAP™の簡単な設定について議論してきた。 しかし、ネットワーク上の通信が引き続き平文であるという現状には対応しない。 これが、Transport Layer Security (TLS)が導入された 理由である。
OpenLDAP™クライアントとサーバは、 RFC 2830(訳注:現在は RFC 4513が最新) Lightweight Directory Access Protocol (v3): Extension for Transport Layer Security. による、完全性と機密性を提供するため、Transport Layer Security (TLS)を使う 能力がある。
TLSはX.509証明書を使う。すべてのサーバは有効な証明書を持つ必要があるが、 クライアント証明書はあってもなくてもよい。ここではサーバ証明書のみを 議論の対象とする。
サーバ証明書のDNはサーバの名前を指定するCN属性を使う必要があり、CNは、サーバの、 完全に記述されたドメイン名(FQDN)を引き継ぐ必要がある。追加の別名と ワイルドカードは、subjectAltName
証明書エクステンションに存在しても よい。サーバ証明書の名前についてのより詳細については、 RFC2830にある。
これについては次の節で詳細に説明する。
適切な証明書を作成するために、固有の認証局(CA)を立てる必要がある。 [8] これは必要であり、そうすると、サーバ証明書に署名できる。
これに対しては、ほとんどのLinux® ディストリビューションに含まれているOpenSSL [9] を使うことになる。
TLSは多くの種類のサーバによって使われるが、その手続きは、 [10] ここで説明されていて、OpenLDAP に特化している。
以下の例におけるCommon Name (CN)は、使用しているLDAPサーバの 完全に記述されたドメイン名(FQDN)でなければならない。
最初に認証局(CA)を生成する必要がある:
root#
mkdir myCA
そのディレクトリに移動する:
root#
cd myCA
Now generate the CA:[11]
root#
/usr/share/ssl/misc/CA.pl -newcaCA certificate filename (or enter to create) Making CA certificate ...Generating a 1024 bit RSA private key.......................++++++.............................++++++writing new private key to './demoCA/private/cakey.pem'Enter PEM pass phrase:Verifying - Enter PEM pass phrase:-----You are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:AUState or Province Name (full name) [Some-State]:NSWLocality Name (eg, city) []:SydneyOrganization Name (eg, company) [Internet Widgits Pty Ltd]:AbmasOrganizational Unit Name (eg, section) []:ITCommon Name (eg, YOUR name) []:ldap.abmas.bizEmail Address []:support@abmas.biz
注意すべき点がいくつかある。
サーバの証明書に署名するのに必要なので、 パスワードを覚えておく必要がある。
Common Name (CN)は使用しているLDAPサーバの 完全に記述されたドメイン名(FQDN)でなければならない。
次にサーバ証明書を生成する必要がある:
root#
openssl req -new -nodes -keyout newreq.pem -out newreq.pemGenerating a 1024 bit RSA private key.............++++++........................................................++++++writing new private key to 'newreq.pem'-----You are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:AUState or Province Name (full name) [Some-State]:NSWLocality Name (eg, city) []:SydneyOrganization Name (eg, company) [Internet Widgits Pty Ltd]:AbmasOrganizational Unit Name (eg, section) []:ITCommon Name (eg, YOUR name) []:ldap.abmas.bizEmail Address []:support@abmas.biz Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:An optional company name []:
繰り返すが、ここでもいくつか注意すべき事がある。
パスワードを入力すべきではない。
Common Name (CN)は使用しているLDAPサーバの 完全に記述されたドメイン名(FQDN)でなければならない。
次に新しい認証局(CA)の証明書に署名する:
root#
/usr/share/ssl/misc/CA.pl -signUsing configuration from /etc/ssl/openssl.cnfEnter pass phrase for ./demoCA/private/cakey.pem:Check that the request matches the signatureSignature okCertificate Details:Serial Number: 1 (0x1)Validity Not Before: Mar 6 18:22:26 2005 EDT Not After : Mar 6 18:22:26 2006 EDTSubject: countryName = AU stateOrProvinceName = NSW localityName = Sydney organizationName = Abmas organizationalUnitName = IT commonName = ldap.abmas.biz emailAddress = support@abmas.bizX509v3 extensions: X509v3 Basic Constraints: CA:FALSE Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: F7:84:87:25:C4:E8:46:6D:0F:47:27:91:F0:16:E0:86:6A:EE:A3:CE X509v3 Authority Key Identifier: keyid:27:44:63:3A:CB:09:DC:B1:FF:32:CC:93:23:A4:F1:B4:D5:F0:7E:CC DirName:/C=AU/ST=NSW/L=Sydney/O=Abmas/OU=IT/ CN=ldap.abmas.biz/emailAddress=support@abmas.biz serial:00Certificate is to be certified until Mar 6 18:22:26 2006 EDT (365 days)Sign the certificate? [y/n]:y1 out of 1 certificate requests certified, commit? [y/n]yWrite out database with 1 new entriesData Base UpdatedSigned certificate is in newcert.pem
これでサーバ証明書の生成が完了する。
次に、正しい設定ディレクトリ中に証明書をコピーする必要があり、その後同時に改名して (利便性のために)、所有権を変更し、最後にアクセス許可を与える:
root#
cp demoCA/cacert.pem /etc/openldap/root#
cp newcert.pem /etc/openldap/servercrt.pemroot#
cp newreq.pem /etc/openldap/serverkey.pemroot#
chown ldap.ldap /etc/openldap/*.pemroot#
chmod 640 /etc/openldap/cacert.pem;root#
chmod 600 /etc/openldap/serverkey.pem
次に、これらのファイル位置情報を、以下のようにして、slapd.conf
の、database
定義の前のどこかに追加する必要がある:
TLSCertificateFile /etc/openldap/servercrt.pemTLSCertificateKeyFile /etc/openldap/serverkey.pemTLSCACertificateFile /etc/openldap/cacert.pem
以下は、ldap.conf
での定義である:ldap.conf
TLS_CACERT /etc/openldap/cacert.pem
これですべてである。次にthe section called “評価”を行う。
root#
/etc/init.d/ldap restartStopping slapd: [ OK ]Checking configuration files for slapd: config file testing succeededStarting slapd: [ OK ]
次に、ldapsearch
を使い、-ZZ
オプションを使って [12] 匿名検索で評価する:
root#
ldapsearch -x -b "dc=ldap,dc=abmas,dc=biz" \ -H 'ldap://ldap.abmas.biz:389' -ZZ
以下のように、サーバを再起動する前と結果は同じであるべきである:
root#
ldapsearch -x -b "dc=ldap,dc=abmas,dc=biz" \ -H 'ldap://ldap.abmas.biz:389' -ZZ# extended LDIF## LDAPv3# base <> with scope sub# filter: (objectclass=*)# requesting: ALL## abmas.bizdn: dc=ldap,dc=abmas,dc=bizobjectClass: dcObjectobjectClass: organizationo: Abmasdc: abmas# Manager, ldap.abmas.bizdn: cn=Manager,dc=ldap,dc=abmas,dc=bizobjectClass: organizationalRolecn: Manager# ABMAS, abmas.bizdn: sambaDomainName=ABMAS,dc=ldap,dc=abmas,dc=bizsambaDomainName: ABMASsambaSID: S-1-5-21-238355452-1056757430-1592208922sambaAlgorithmicRidBase: 1000objectClass: sambaDomainsambaNextUserRid: 67109862sambaNextGroupRid: 67109863
何か問題が起きた場合は、the section called “トラブルシューティング”を読んでみてほしい。
TLSを設定しているときに最もよくあるエラーは、何回も説明したように、the section called “サーバ証明書の生成”で入力したCommon Name (CN)が、使用しているLDAPサーバの、完全に記述されたドメイン名(FQDN)でないというものである。
他のエラーとしては、ldapsearch
コマンドのどこかでタイプミスしたとか、servercrt.pem
とcacert.pem
に間違ったアクセス許可を設定しているかである。the section called “証明書のインストール”単位にchmod 640
で設定すべきである。
それ以外は、ldapのログファイルを読むか、OpenLDAPメーリングリストに参加するのが最も良い方法である。
[9] 固有の認証局(CA)を作ることの不都合な点は、商用のものがそうであるように、 証明書がクライアントによって自動的に認識されないということである。
[10] 一番確かなところからの情報は、 http://www.openssl.org/docs/HOWTO/ のmain OpenSSLサイトを参照のこと。
[11] Your CA.pl
or CA.sh
might not be in the same location as mine is, you can find it by using the locate
command, i.e., locate CA.pl
. If the command complains about the database being too old, run updatedb
as root to update it.
[12] man ldapsearch
を参照