絶対もっとスマートな方法ある。誰か教えて。
0.0 環境
Vietual Box 6.1.24
Rocky 8.5(GUI)
1.0 インストール
1.0.1 goのインストール
goのインストール
# cd /root
# pwd
/root
# curl -OL https://go.dev/dl/go1.16.15.linux-amd64.tar.gz //バージョンは1.16がいいらしい(あまりよく知らない)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 76 100 76 0 0 141 0 --:--:-- --:--:-- --:--:-- 141
100 123M 100 123M 0 0 12.7M 0 0:00:09 0:00:09 --:--:-- 15.7M
# tar -C /usr/local -xzf go1.16.15.linux-amd64.tar.gz
1.0.2 PATH環境変数の追加
PATH環境変数の追加
# echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
# export PATH=$PATH:/usr/local/go/bin
# echo $PATH
# go version //goコマンドにパスが通るのでバージョン確認してみる
go version go1.16.15 linux/amd64
1.0.3 cfsslのインストール
cfsslのインストール(go 1.16)
# go get github.com/cloudflare/cfssl/cmd/...
go: downloading github.com/cloudflare/cfssl v1.6.3
(略)
goのバージョンが1.18以上の場合は以下で可能らしい(READMEを参照:https://github.com/cloudflare/cfssl/blob/master/README.md)
cfsslのインストール(go 1.18↑)
# go get github.com/cloudflare/cfssl/cmd/...
go: downloading github.com/cloudflare/cfssl v1.6.3
(略)
cfsslのインストール(共通)
# ls -l /root/go/bin/
合計 111700
-rwxr-xr-x 1 root root 19988976 12月 5 15:48 cfssl
-rwxr-xr-x 1 root root 13062208 12月 5 15:48 cfssl-bundle
-rwxr-xr-x 1 root root 16149080 12月 5 15:48 cfssl-certinfo
-rwxr-xr-x 1 root root 13901296 12月 5 15:48 cfssl-newkey
-rwxr-xr-x 1 root root 13559345 12月 5 15:48 cfssl-scan
-rwxr-xr-x 1 root root 10387555 12月 5 15:48 cfssljson
-rwxr-xr-x 1 root root 6741873 12月 5 15:48 mkbundle
-rwxr-xr-x 1 root root 20571944 12月 5 15:49 multirootca
# mv /root/go/bin/* /usr/local/bin/
# whereis cfssl
cfssl: /usr/local/bin/cfssl
1.1テスト(CSR作成)
JSONファイル管理用ディレクトリ作成
# mkdir -p /root/cfssltest/json
証明書内容記載JSONファイル作成
# vi /root/cfssltest/json/test.json
{
"CN":"hogehoge.exsample.co.jp",
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "JP",
"ST": "Tokyo",
"L": "minato-ku",
"O": "company-kabusikigaisha",
"OU": "sushi-tabetai"
}
]
}
CSR/秘密鍵作成
# cfssl genkey /root/cfssltest/json/test.json | cfssljson -bare cfssl-test
2022/12/05 15:58:44 [INFO] generate received request
2022/12/05 15:58:44 [INFO] received CSR
2022/12/05 15:58:44 [INFO] generating key: rsa-2048
2022/12/05 15:58:44 [INFO] encoded CSR
# ls -l /root | grep cfssl-test
-rw------- 1 root root 1679 12月 5 15:58 cfssl-test-key.pem
-rw-r--r-- 1 root root 1054 12月 5 15:58 cfssl-test.csr
CSR内容確認
# openssl req --noout --text -in cfssl-test.csr
Certificate Request:
Data:
Version: 1 (0x0)
Subject: C = JP, ST = Tokyo, L = minato-ku, O = company-kabusikigaisha, OU = sushi-tabetai, CN = hogehoge.exsample.co.jp
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (2048 bit)
(略)
2.0 参考
公式README:https://github.com/cloudflare/cfssl/blob/master/README.md
CentOs8 Go言語のインストール:https://mebee.info/2019/10/24/post-2402/
SSL証明書発行ではcfsslを使おう(opensslめんどくさい):https://qiita.com/AkiQ/items/5489033346a12c55ff43
goソース取得元:https://go.dev/dl/