1
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?

Symbolノードの証明書を生成する

Last updated at Posted at 2025-04-19

OpenSSL を使用した Symbol 証明書の生成方法(ランダムキー)の紹介です。

確認した環境

この記事では、以下の環境で動作確認してます。

  • Ubuntu 24.04
  • OpenSSL 3.0.13

CA(認証局) 証明書

CA 証明書秘密鍵を作る

CA 証明書の秘密鍵を作ります。
bootstrap でいうところのメインアカウントになります。

openssl genpkey \
    -algorithm ed25519 \
    -outform PEM \
    -out ca.key.pem

証明書を保存するフォルダを準備

証明書を保存するフォルダを作ります。

mkdir -p cert/new_certs
cd cert

この後の作業は、cert フォルダの中で進めていきます。

CA 証明書を作る

ca.cnf という設定ファイルを作ります。
[dn] セクションの CN には認証局の名前を入れます。好きな名前を設定してください。

ca.cnf
[ca]
default_ca = CA_default

[CA_default]
new_certs_dir = ./new_certs
database = index.txt
serial = serial.dat
private_key = ../ca.key.pem
certificate = ca.crt.pem
policy = policy_catapult

[policy_catapult]
commonName = supplied

[req]
prompt = no
distinguished_name = dn
x509_extensions = x509_v3_ca

[dn]
CN = Symbol CA

[x509_v3_ca]
basicConstraints = critical,CA:TRUE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer

[x509_v3_node]
basicConstraints = CA:FALSE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer

index.txt という名前の空ファイルを作ります。

touch index.txt

証明書のシリアル番号をランダムに生成します。

openssl rand -out serial.dat -hex 19

以下のコマンドを使って CA 証明書を作ります。
-days オプションで証明書の有効期間を指定できます。

openssl req \
    -new \
    -x509 \
    -config ca.cnf \
    -keyform PEM \
    -key ../ca.key.pem \
    -days 7300 \
    -out ca.crt.pem \
    -extensions x509_v3_ca

Node 証明書

bootstrap でいうところのトランスポートアカウントになります。

Node 証明書秘密鍵を作る

Node 証明書の秘密鍵を作ります。

openssl genpkey \
    -algorithm ed25519 \
    -outform PEM \
    -out node.key.pem

Node CSR を作る

証明書署名要求 (Certificate Signing Request)

node.cnf という設定ファイルを作ります。
[dn] セクションの CN には証明書の名前を入れます。好きな名前を設定してください。

node.cnf
[req]
prompt = no
distinguished_name = dn

[dn]
CN = Symbol Node

以下のコマンドを使って CSR を作ります。

openssl req \
    -new \
    -config node.cnf \
    -key node.key.pem \
    -out node.csr.pem

Node 証明書に署名する

Node 証明書に署名します。これで Node 証明書が生成されます。

openssl ca \
    -batch \
    -notext \
    -config ca.cnf \
    -days 375 \
    -in node.csr.pem \
    -out node.crt.pem \
    -extensions x509_v3_node

CA 証明書と Node 証明書を連結

Node 証明書、CA 証明書の順で連結します。

cat node.crt.pem ca.crt.pem > node.full.crt.pem

CA 証明書秘密鍵の後始末

CA 証明書秘密鍵は、ノードメインアカウントの秘密鍵でもあるので、削除または安全な場所に保管します。ノード間の通信や Node 証明書の更新では使用しません。

1
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
1
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?