Apache 設定ファイルの中の SSL 関連ファイル指定

SSLCertificateFileSSLサーバ証明書ファイル
SSLCertificateKeyFileSSLサーバ証明書とペアになる秘密鍵
SSLCertificateChainFileサーバー証明書における中間証明書
SSLCACertificateFileクライアント証明書における中間証明書のパスを設定

サーバ証明書の作成

独自認証局の秘密鍵、ルート証明書(CA)の作成

munakata@mvc:$ cd /etc/ssl/client_unofficial
munakata@mvc:/etc/ssl/client_unofficial$ sudo mkdir -p demoCA/{private,newcerts}
munakata@mvc:/etc/ssl/client_unofficial$ cd demoCA
munakata@mvc:/etc/ssl/client_unofficial/demoCA$ sudo sh -c "echo 01 > serial"
munakata@mvc:/etc/ssl/client_unofficial/demoCA$ sudo openssl req -x509 -days 3650 -newkey rsa:2048 -keyout private/cakey.pem -out cacert.pem -subj "/C=JP/ST=Kanagawa/O=local/OU=IT admin/CN=$(hostname)"
Generating a 2048 bit RSA private key
................................................................................+++
......................................................................+++
writing new private key to 'private/cakey.pem'
Enter PEM pass phrase:   <---- magumagunana
Verifying - Enter PEM pass phrase:
-----
file備考
private/cakey.pem秘密鍵&ref(): File not found: "cakey.pem" at page "HomeServer17";
cacert.pem認証局(CA)証明書filecacert.pem

秘密鍵とサーバ署名要求(CSR)の作成

munakata@mvc:/etc/ssl/client_unofficial$ sudo openssl req -newkey rsa:2048 -keyout newkey.pem -out newreq.pem -subj "/C=JP/ST=Kanagawa/O=local/OU=IT Admin/CN=$(hostname)"
Generating a 2048 bit RSA private key
..+++
.....................+++
writing new private key to 'newkey.pem'
Enter PEM pass phrase:   <----- nanamocha
Verifying - Enter PEM pass phrase:
-----
file備考
newkey.pemホストキー(パスワードあり)&ref(): File not found: "newkey.pem" at page "HomeServer17";
newreq.pemホスト証明書filenewreq.pem

パスワードなしのホストキー作成 (apache に組み込む用)

munakata@mvc:/etc/ssl/client_unofficial$ sudo openssl rsa -in newkey.pem -out nokey.pem
Enter pass phrase for newkey.pem:  <----- nanamocha
writing RSA key

CSRへの署名

munakata@mvc:/etc/ssl/client_unofficial$ sudo openssl ca -in demoCA/newreq.pem -days 3650 -out demoCA/cert.pem -notext
Using configuration from /usr/lib/ssl/openssl.cnf
Enter pass phrase for ./demoCA/private/cakey.pem:   <---- magumagunana
Can't open ./demoCA/index.txt.attr for reading, No such file or directory
139919263568320:error:02001002:system library:fopen:No such file or 
directory:../crypto/bio/bss_file.c:74:fopen('./demoCA/index.txt.attr','r')
139919263568320:error:2006D080:BIO routines:BIO_new_file:no such file:../crypto/bio/bss_file.c:81:
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Mar 18 02:07:50 2019 GMT
            Not After : Mar 15 02:07:50 2029 GMT
        Subject:
            countryName               = JP
            stateOrProvinceName       = Kanagawa
            organizationName          = local
            organizationalUnitName    = IT Admin
            commonName                = mvc
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                C7:72:07:0B:AB:C0:08:A9:96:92:05:4E:AB:A2:A8:A4:3D:45:A2:B4
            X509v3 Authority Key Identifier: 
                keyid:18:72:B0:E7:32:18:BA:7A:AB:4C:20:CD:9F:81:31:95:AF:11:A1:78

Certificate is to be certified until Mar 15 02:07:50 2029 GMT (3650 days)
Sign the certificate? [y/n]:Y

1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

openssl.cnfを編集

munakata@mvc:/etc/ssl/client_unofficial$ cd demoCA/
munakata@mvc:/etc/ssl/client_unofficial/demoCA$ sudo cp -a /etc/ssl/openssl.cnf .
munakata@mvc:/etc/ssl/client_unofficial/demoCA$ ls -l
合計 56
-rw-r--r-- 1 root root  1261  3月 18 09:53 cacert.pem
-rw-r--r-- 1 root root  1306  3月 18 11:08 cert.pem
-rw-r--r-- 1 root root    73  3月 18 11:08 index.txt
-rw-r--r-- 1 root root    21  3月 18 11:08 index.txt.attr
-rw-r--r-- 1 root root     0  3月 18 10:54 index.txt.old
drwxr-xr-x 2 root root  4096  3月 18 11:08 newcerts
-rw------- 1 root root  1854  3月 18 10:23 newkey.pem
-rw-r--r-- 1 root root   972  3月 18 10:23 newreq.pem
-rw------- 1 root root  1675  3月 18 10:44 nokey.pem
-rw-r--r-- 1 root root 10835  4月  8  2014 openssl.cnf
drwxr-xr-x 2 root root  4096  3月 18 09:53 private
-rw-r--r-- 1 root root     3  3月 18 11:08 serial
-rw-r--r-- 1 root root     3  3月 18 09:47 serial.old

証明書失効リスト用

munakata@mvc:/etc/ssl/client_unofficial/demoCA$ sudo sh -c "echo "00" > crlnumber"

3種類の認証を組み合わせ

<Directory /mnt/raid_vol/html/pukiwiki>↲↲
    <RequireAny>↲
        # ローカルネットからはパスワードなしアクセスを許可↲
        Require ip 172.0.0.1↲
        Require ip 192.168.1↲
↲
        # それ以外は Google Authentificator を利用↲
        <RequireAll>↲
        AuthType Basic↲
        AuthName "Enter OTP password"↲
            AuthBasicProvider OTP↲
            Require valid-user↲
            OTPAuthUsersFile /mnt/raid_vol/html/otp/users↲
            OTPAuthMaxLinger 3600↲
            OTPAuthLogoutOnIPChange On↲
        </RequireAll>↲
    </RequireAny>↲

参考 URL


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS