0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ACME対応プライベート認証局をsmallstepのstep-caで作ってみる

Last updated at Posted at 2025-10-16

目的

プライベート認証局を立てる

環境

  • OS: Locky Linux 9
  • ドメイン: example.local
  • FQDN: jaguar.example.local
  • IPアドレス: 192.168.56.17
  • DNS: 192.168.56.18 (cheetah.example.local)

事前準備

  • DNSに jaguar.example.local の Aレコードを登録しておく
  • nameserverの向き先を192.168.56.18にしておく

インストール

リポジトリアクセス用のファイル作成

console
# cat <<EOT > /etc/yum.repos.d/smallstep.repo
[smallstep]
name=Smallstep
baseurl=https://packages.smallstep.com/stable/fedora/
enabled=1
repo_gpgcheck=0
gpgcheck=1
gpgkey=https://packages.smallstep.com/keys/smallstep-0x889B19391F774443.gpg
EOT

パッケージ管理ツールのキャッシュ更新

console
# dnf makecache

インストール

# dnf install step-cli step-ca

初期設定

初期設定

console
$ step ca init --acme
✔ Deployment Type: Standalone
What would you like to name your new PKI?
✔ (e.g. Smallstep): EXAMPLE.LOCAL    ← 「EXAMPLE.LOCAL」と入力
What DNS names or IP addresses will clients use to reach your CA?
✔ (e.g. ca.example.com[,10.1.2.3,etc.]): jaguar.example.local,192.168.56.17    ← 自身のFQDN,IPアドレスを入力
What IP and port will your new CA bind to? (:443 will bind to 0.0.0.0:443)(e.g. :443 or 127.0.0.1:443): :443    ← 「:443」と入力
What would you like to name the CA's first provisioner?
✔ (e.g. you@smallstep.com): test@example.local    ← 「test@example.local」と入力
Choose a password for your CA keys and first provisioner.
✔ [leave empty and we'll generate one]:    ← 何も入力しないでEnterキー押下
✔ Password: 09QufJKzdkRJcoGfh7CPsmbb2WHFR9Za    ← 後で使うのでメモしておく
	
Generating root certificate... done!
Generating intermediate certificate... done!
	
✔ Root certificate: /root/.step/certs/root_ca.crt
✔ Root private key: /root/.step/secrets/root_ca_key
✔ Root fingerprint: 7e1d9cc23fe0a0cf84e2acdc502edfd20bcf97183dec073ea4e479a918429327
✔ Intermediate certificate: /root/.step/certs/intermediate_ca.crt
✔ Intermediate private key: /root/.step/secrets/intermediate_ca_key
✔ Database folder: /root/.step/db
✔ Default configuration: /root/.step/config/defaults.json
✔ Certificate Authority configuration: /root/.step/config/ca.json
	
Your PKI is ready to go. To generate certificates for individual services see 'step help ca'.
	
FEEDBACK 😍 🍻
  The step utility is not instrumented for usage statistics. It does not phone
  home. But your feedback is extremely valuable. Any information you can provide
  regarding how you’re using `step` helps. Please send us a sentence or two,
  good or bad at feedback@smallstep.com or join GitHub Discussions
  https://github.com/smallstep/certificates/discussions and our Discord
  https://u.step.sm/discord.

生成されたファイルの確認

console
# find ~/.step/ -type f | xargs file
/root/.step/certs/root_ca.crt:           PEM certificate
/root/.step/certs/intermediate_ca.crt:   PEM certificate
/root/.step/secrets/root_ca_key:         PEM EC private key
/root/.step/secrets/intermediate_ca_key: PEM EC private key
/root/.step/config/ca.json:              JSON data
/root/.step/config/defaults.json:        JSON data

サーバー起動

セットアップ時に指定したポート(:443)がApacheのHTTPSなどの他のサービスが使っていないことを確認すること。

console
// 起動
# step-ca /root/.step/config/ca.json

// 待ち受け確認
# ss -ltnp | grep 443
LISTEN 0      4096               *:443              *:*    users:(("step-ca",pid=2303,fd=10))

root-ca(自分自身)の証明書設定

自身の証明書が作成されているのでそれを確認する。
ここで作成するacme.crt(root-caの証明書)はこのサーバーとのTLS通信時に必要となる。

console
// 閲覧
# step ca root | openssl x509 -text -noout

// crtファイルとして出力
# step ca root acme.crt
The root certificate has been saved in acme.crt.

// 出力したファイルの属性値を確認
# file acme.crt
acme.crt: PEM certificate

ポート開放

他のサーバーからの通信を受け入れるため、ポートを開放する

console
# firewall-cmd --add-service=http --zone=public --permanent
# firewall-cmd --add-aservice=https --zone=public --permanent
# firewall-cmd --reload
# firewall-cmd --list-services
http https ssh

この後の展開

この後は全て別のサーバーでの作業となる。DNS・認証局を起動させたまま作業を行う
ウェブサーバーを立ててバーチャルホストの設定をする
root-ca証明書を入手してサーバーにインストールする
ウェブサーバーと認証局のTLS通信疎通テスト
certbotをインストールして認証局に自身の証明書の署名をしてもらう

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?