この例では、repo1、repo2、および repo3 という名前の 3 つのセキュアなリポジトリを構成します。repo1 および repo2 リポジトリは、専用の証明書を使用して構成します。このため、repo1 の証明書は repo2 では機能せず、repo2 の証明書は repo1 では機能しません。repo3 リポジトリは、どちらの証明書も受け入れるように構成します。
この例では、Apache インスタンスの適切なサーバー証明書がすでに利用可能であることを想定しています。Apache インスタンスのサーバー証明書がない場合は、自己署名付きサーバー認証局の作成のテスト証明書の作成の手順を参照してください。
3 つのリポジトリが、https://pkg-sec.example.com/repo1、https://pkg-sec.example.com/repo2、および https://pkg-sec.example.com/repo3 に設定されます。これらのリポジトリは、 http://internal.example.com でポート 10001、10002、および 10003 にそれぞれ設定されている集積サーバーを指しています。SOFTTOKEN_DIR 環境変数が、キーストアの作成の説明に従って正しく設定されていることを確認します。
$ pktool gencert label=repo1_ca subject="CN=repo1" serial=0x01 $ pktool export objtype=cert label=repo1_ca outformat=pem \ outfile=repo1_ca.pem
$ pktool gencert label=repo2_ca subject="CN=repo2" serial=0x01 $ pktool export objtype=cert label=repo2_ca outformat=pem \ outfile=repo2_ca.pem
$ cat repo1_ca.pem > repo_cas.pem $ cat repo2_ca.pem >> repo_cas.pem $ cp repo_cas.pem /path-to-certs
$ pktool gencsr subject="C=US,CN=myuser" label=repo1_0001 format=pem \ outcsr=repo1_myuser.csr $ pktool signcsr signkey=repo1_ca csr=repo1_myuser.csr \ serial=0x02 outcert=repo1_myuser.crt.pem issuer="CN=repo1" $ pktool export objtype=key label=repo1_0001 outformat=pem \ outfile=repo1_myuser.key.pem $ cp repo1_myuser.key.pem /path-to-certs $ cp repo1_myuser.crt.pem /path-to-certs
$ pktool gencsr subject="C=US,CN=myuser" label=repo2_0001 format=pem \ outcsr=repo2_myuser.csr $ pktool signcsr signkey=repo2_ca csr=repo2_myuser.csr \ serial=0x02 outcert=repo2_myuser.crt.pem issuer="CN=repo2" $ pktool export objtype=key label=repo2_0001 outformat=pem \ outfile=repo2_myuser.key.pem $ cp repo2_myuser.key.pem /path-to-certs $ cp repo2_myuser.crt.pem /path-to-certs
httpd.conf ファイルの最後に次の SSL 構成を追加します。
# Let Apache listen on the standard HTTPS port Listen 443 <VirtualHost 0.0.0.0:443> # DNS domain name of the server ServerName pkg-sec.example.com # enable SSL SSLEngine On # Location of the server certificate and key. # You either have to get one from a certificate signing authority like # VeriSign or create your own CA for testing purposes (see "Creating a # Self-Signed CA for Testing Purposes") SSLCertificateFile /path/to/server.crt SSLCertificateKeyFile /path/to/server.key # Intermediate CA certificate file. Required if your server certificate # is not signed by a top-level CA directly but an intermediate authority. # Comment out this section if you don't need one or if you are using a # test certificate SSLCertificateChainFile /path/to/ca_intermediate.pem # CA certs for client verification. # This is where the CA certificate created in step 3 needs to go. # If you have multiple CAs for multiple repos, just concatenate the # CA certificate files SSLCACertificateFile /path/to/certs/repo_cas.pem # If the client presents a certificate, verify it here. If it doesn't, # ignore. # This is required to be able to use client-certificate based and # anonymous SSL traffic on the same VirtualHost. SSLVerifyClient optional <Location /repo1> SSLVerifyDepth 1 SSLRequire ( %{SSL_CLIENT_I_DN_CN} =~ m/repo1/ ) # proxy request to depot running at internal.example.com:10001 ProxyPass http://internal.example.com:10001 nocanon max=500 </Location> <Location /repo2> SSLVerifyDepth 1 SSLRequire ( %{SSL_CLIENT_I_DN_CN} =~ m/repo2/ ) # proxy request to depot running at internal.example.com:10002 ProxyPass http://internal.example.com:10002 nocanon max=500 </Location> <Location /repo3> SSLVerifyDepth 1 SSLRequire ( %{SSL_CLIENT_VERIFY} eq "SUCCESS" ) # proxy request to depot running at internal.example.com:10003 ProxyPass http://internal.example.com:10003 nocanon max=500 </Location> </VirtualHost>
$ pkg set-publisher -k /path-to-certs/repo1_myuser.key.pem \ -c /path-to-certs/repo1_myuser.crt.pem \ -p https://pkg-sec.example.com/repo1/
$ pkg set-publisher -k /path-to-certs/repo2_myuser.key.pem \ -c /path-to-certs/repo2_myuser.crt.pem \ -p https://pkg-sec.example.com/repo2/
repo1 証明書を使用して、repo3 へのアクセスをテストします。
$ pkg set-publisher -k /path-to-certs/repo1_myuser.key.pem \ -c /path-to-certs/repo1_myuser.crt.pem \ -p https://pkg-sec.example.com/repo3/
repo2 証明書を使用して、repo3 へのアクセスをテストします。
$ pkg set-publisher -k /path-to-certs/repo2_myuser.key.pem \ -c /path-to-certs/repo2_myuser.crt.pem \ -p https://pkg-sec.example.com/repo3/