2019-10-23 01:19 PM 2019-10-23 02:05 PM 更新
以前、OpenSSLによる証明書検証環境構築(802.1x,CRL,OCSP) を投稿しましたが、ISEへの適用とよりシンプルな内容で書き直しました。
今回はWindows 10のWSL(Ubuntu 18.04.LTS)をopensslの環境として使用しています。ISEは2.4/2.6で確認しています。
なるべく既存の環境への考慮が不要でやり直しが手軽な方法を目指します。
HOME = .
RANDFILE = $ENV::HOME/.rnd
[ ca ]
default_ca = CA_default
[ CA_default ]
database = ./index.txt
new_certs_dir = .
serial = ./serial
crlnumber = ./crlnumber
RANDFILE = ./.rand
crl_extensions = crl_ext
preserve = no
policy = policy_match
copy_extensions = copy
[ policy_match ]
countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
[ req ]
distinguished_name = req_distinguished_name
string_mask = utf8only
[ req_distinguished_name ]
[ rca ]
subjectKeyIdentifier = hash
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
[ ica ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always, issuer
basicConstraints = critical, CA:TRUE, pathlen:0
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
[ usr ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid, issuer
basicConstraints = CA:FALSE
[ crl_ext ]
authorityKeyIdentifier=keyid:always,issuer
[ ocsp ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
basicConstraints = CA:FALSE
keyUsage = critical, digitalSignature, keyEncipherment, nonRepudiation
extendedKeyUsage = critical, OCSPSigning
#noCheck=yes
authorityInfoAccess = OCSP;URI:http://ocsp.hogetrust.com:2560
echo '01' > ./serial && echo '00' > ./crlnumber && touch ./index.txt
証明書chainを作り直す場合は、別のdirectoryを作成し上記を繰りかえす(不要になればdirectoryごと削除)。他への影響は考慮不要。
openssl req -new -x509 -config openssl.cfg -extensions rca -passout pass:cisco123 -newkey rsa:2048 -subj "/C=JP/ST=Tokyo/L=Roppongi/O=HogeSystems/OU=RCA191021/CN=rca.hogesystems.com/emailAddress=rca-admin@hogesystems.com" -days 3650 -keyout rcakey.pem > rcacrt.pem -batch
"/C=JP/ST=Tokyo/L=Roppongi/O=HogeSystems/OU=RCA191021/CN=rca.hogesystems.com/emailAddress=rca-admin@hogesystems.com"
の部分は証明書のsubjectになるので適当に変更。
自分で自分に署名するのでCSRは不要。
ISEではSubjectが既存と被ると問題が出る時があるのでOUだけ日時で変えておくというのも手です。証明書の有効期限等他にもcustomize可能ですが、opensslに関してはInternetに多くの記事があるので必要に応じて確認下さい。
openssl req -new -config openssl.cfg -sha256 -passout pass:cisco123 -newkey rsa:2048 -subj "/C=JP/ST=Tokyo/L=Roppongi/O=HogeSystems/OU=ICA191021/CN=ica.hogesystems.com/emailAddress=ica-admin@hogesystems.com" -keyout icakey.pem > icacsr.pem -batch
openssl ca -config openssl.cfg -notext -extensions ica -md sha256 -passin pass:cisco123 -keyfile rcakey.pem -cert rcacrt.pem -in icacsr.pem -days 1825 > icacrt.pem -batch
"/C=JP/ST=Tokyo/L=Roppongi/O=HogeSystems/OU=ICA191021/CN=ica.hogesystems.com/emailAddress=ica-admin@hogesystems.com"
の部分が証明書のsubject。ここまでで以下のようにファイルが生成。
[19/10/21 23:40] 191021$ ls -la
total 0
drwxrwxrwx 1 hiyoko hiyoko 4096 Oct 21 23:40 .
drwxr-xr-x 1 hiyoko hiyoko 4096 Oct 21 22:54 ..
-rw-rw-rw- 1 hiyoko hiyoko 1476 Oct 21 23:40 01.pem
-rw-rw-rw- 1 hiyoko hiyoko 3 Oct 21 22:56 crlnumber
-rw-rw-rw- 1 hiyoko hiyoko 1476 Oct 21 23:40 icacrt.pem
-rw-rw-rw- 1 hiyoko hiyoko 1086 Oct 21 23:36 icacsr.pem
-rw------- 1 hiyoko hiyoko 1854 Oct 21 23:36 icakey.pem
-rw-rw-rw- 1 hiyoko hiyoko 132 Oct 21 23:40 index.txt
-rw-rw-rw- 1 hiyoko hiyoko 21 Oct 21 23:40 index.txt.attr
-rw-rw-rw- 1 hiyoko hiyoko 0 Oct 21 22:56 index.txt.old
-rw-r--r-- 1 hiyoko hiyoko 1439 Oct 21 22:56 openssl.cfg
-rw-rw-rw- 1 hiyoko hiyoko 1464 Oct 21 23:35 rcacrt.pem
-rw------- 1 hiyoko hiyoko 1854 Oct 21 23:35 rcakey.pem
-rw-rw-rw- 1 hiyoko hiyoko 3 Oct 21 23:40 serial
-rw-rw-rw- 1 hiyoko hiyoko 3 Oct 21 22:56 serial.old
[19/10/21 23:40] 191021$
本投稿ではXXXcrt.pemが証明書、XXXkey.pemが秘密鍵、XXXcsr.pemがCSRとする。
CA証明書の秘密鍵のpassphraseはcisco123, 証明書の秘密鍵のpassphraseはcisco とする。
openssl req -new -sha256 -newkey rsa:2048 -passout pass:cisco -subj "/C=JP/ST=Tokyo/L=Roppongi/O=HogeSystems/OU=CX/CN=cse01/emailAddress=cse01@hogesystems.com" -reqexts EXTS -config <(cat ./openssl.cfg <(printf "\n[EXTS]\nkeyUsage=critical,digitalSignature,keyEncipherment\nextendedKeyUsage=clientAuth,emailProtection")) -keyout usr01key.pem -out usr01csr.pem -batch
openssl ca -config openssl.cfg -notext -extensions usr -passin pass:cisco123 -md sha256 -keyfile icakey.pem -cert icacrt.pem -in usr01csr.pem -days 365 -out usr01crt.pem -batch
extendedKeyUsageにcilentAuthを含む。
usr01の部分をusr02,usr03と変更していけば複数の証明書を作成可能。
subjectは適宜変更可能。
openssl req -new -sha256 -newkey rsa:2048 -passout pass:cisco -subj "/C=JP/ST=Tokyo/L=Roppongi/O=HogeSystems/OU=CX/CN=svr01.hogesystems.com" -reqexts EXTS -config <(cat ./openssl.cfg <(printf "\n[EXTS]\nsubjectAltName=DNS:ise22.hogesystems.com,DNS:www.hogesystems.com,IP:1.1.1.1\nkeyUsage=critical,digitalSignature,keyEncipherment\nextendedKeyUsage=serverAuth")) -keyout svr01key.pem -out svr01csr.pem -batch
openssl ca -config openssl.cfg -notext -extensions usr -passin pass:cisco123 -md sha256 -keyfile icakey.pem -cert icacrt.pem -in svr01csr.pem -days 365 -out svr01crt.pem -batch
extendedKeyUsageにserverAuthを含む。
subjectは既存のものと被らないようにする。
SANはbrowserに入力する可能性のあるFQDNやIPを設定します。複数入れることも可能(特にadmin/portal usage)
-passin は署名に使用するca証明書の秘密鍵のpassphrase, -passoutはCSRを作成する際のpassphraseで-batchでy入力を省略できるようにしている。
bashの内部コマンドのprintfでEKUやSubject/SANを証明書ごとに自由に設定できるようにしている。
openssl ca -config openssl.cfg -md sha256 -cert icacrt.pem -passin pass:cisco123 -keyfile icakey.pem -revoke usr01crt.pem
[19/10/22 08:23] 191021$ cat index.txt
V 241019144042Z 01 unknown /C=JP/ST=Tokyo/O=HogeSystems/OU=ICA191021/CN=ica.hogesystems.com/emailAddress=ica-admin@hogesystems.com
R 201020145717Z 191021232303Z 02 unknown /C=JP/ST=Tokyo/O=HogeSystems/OU=CX/CN=cse01/emailAddress=cse01@hogesystems.com
V 201020151054Z 03 unknown /C=JP/ST=Tokyo/O=HogeSystems/OU=JTAC/CN=svr01.hogesystems.com
V 201020151720Z 04 unknown /C=JP/ST=Tokyo/O=HogeSystems/OU=CX/CN=cse02/emailAddress=cse02@hogesystems.com
[19/10/22 08:23] 191021$
openssl ca -gencrl -config openssl.cfg -md sha256 -cert icacrt.pem -passin pass:cisco123 -keyfile icakey.pem -crldays 30 > icacrl.pem
[19/10/22 15:01] 191021-2$ openssl verify -crl_check -CRLfile icacrl.pem -CAfile <(cat rcacrt.pem icacrt.pem) usr01crt.pem
C = JP, ST = Tokyo, O = HogeSystems, OU = CX, CN = cse01, emailAddress = cse01@hogesystems.com
error 23 at 0 depth lookup: certificate revoked
error usr01crt.pem: verification failed
openssl req -new -config openssl.cfg -sha256 -newkey rsa:2048 -subj "/C=JP/ST=Tokyo/L=Roppongi/O=HogeSystems/OU=CX/CN=iocsp.hogesystems.com" -passout pass:cisco -keyout iocspkey.pem -out iocspcsr.pem -batch
openssl ca -config openssl.cfg -extensions ocsp -md sha256 -passin pass:cisco123 -keyfile icakey.pem -cert icacrt.pem -in iocspcsr.pem -days 365 -out iocspcrt.pem -batch
openssl ocsp -ignore_err -index index.txt -CA icacrt.pem -rsigner iocspcrt.pem -passin pass:cisco -rkey iocspkey.pem -port 2560
openssl ocsp -issuer icacrt.pem -nonce -CAfile <(cat rcacrt.pem icacrt.pem) -url http://localhost:2560 -serial 2
[19/10/22 14:21] 191021-2$ openssl ocsp -issuer icacrt.pem -nonce -CAfile <(cat rcacrt.pem icacrt.pem) -url http://localhost:2560 -serial 2
Response verify OK
2: revoked
This Update: Oct 22 05:21:11 2019 GMT
Revocation Time: Oct 22 03:44:00 2019 GMT
[19/10/22 14:21] 191021-2$ openssl ocsp -issuer icacrt.pem -nonce -CAfile <(cat rcacrt.pem icacrt.pem) -url http://localhost:2560 -serial 3
Response verify OK
3: good
This Update: Oct 22 05:21:35 2019 GMT
Administration > System > Certificates > Certificate Management > Trusted Certificates > Import
Administration > System > Certificates > Certificate Management > System Certificates > Import
Control panel > Network Connections (ncpa.cpl)から当該NICで
右クリック -> Properties > Authentication で、802.1x設定
Verify the server's Identity by validating the certificate にcheckが入っている場合は端末がISEのEAP server証明書を信頼している必要があるので、
Administration > System > Certificates > Certificate Management > Trusted Certificates
Administration > System > Certificates > Certificate Management > OCSP Client Profile
openssl verify (証明書の検証確認)
[19/10/22 14:59] 191021-2$ openssl verify -CAfile <(cat rcacrt.pem icacrt.pem) usr01crt.pem
usr01crt.pem: OK
openssl x509 -text -noout (証明書の内容確認)
[19/10/22 15:02] 191021-2$ openssl x509 -text -noout < usr01crt.pem
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 2 (0x2)
Signature Algorithm: sha256WithRSAEncryption
Issuer: C = JP, ST = Tokyo, O = HogeSystems, OU = ICA191021, CN = ica.hogesystems.com, emailAddress = ica-admin@hogesystems.com
Validity
Not Before: Oct 22 03:41:34 2019 GMT
Not After : Oct 21 03:41:34 2020 GMT
Subject: C = JP, ST = Tokyo, O = HogeSystems, OU = CX, CN = cse01, emailAddress = cse01@hogesystems.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
(snip)
openssl pkcs12 -export (証明書と秘密鍵をpkcs12に変換、Windowsにclient証明書としてimport)
[19/10/22 15:11] 191021-2$ openssl pkcs12 -export -passout pass:cisco -passin pass:cisco -inkey usr01key.pem < usr01crt.pem > usr01crt.p12
openssl x509 -inform pem -outform der < usr01crt.pem > usr01crt.der (PEMからDERに変換)
市販の証明書で使われている多くのattribute/機能はopensslで大部分カバーできます。証明書関連の問題が発生しているときに検証環境を構築する敷居が下がればと思います。
検索バーにキーワード、フレーズ、または質問を入力し、お探しのものを見つけましょう
シスコ コミュニティをいち早く使いこなしていただけるよう役立つリンクをまとめました。みなさんのジャーニーがより良いものとなるようお手伝いします
下記より関連するコンテンツにアクセスできます