2
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-16

インストール済だとは思いますが OpenSSL が必要です。

CA 証明書と Node 証明書のどちらも参照できます。

check_certs.sh
#!/bin/bash

set -e

# 引数チェック
if [ $# -lt 1 ]; then
    echo "Usage: $0 <host> [port]"
    exit 1
fi

HOST="$1"
PORT="${2:-7900}"  # デフォルト7900

# 一時ディレクトリ作成(trapで自動削除)
WORKDIR=$(mktemp -d)
CERTFILE="$WORKDIR/all_certs.pem"

# スクリプト終了時に一時ファイル削除
cleanup() {
    rm -rf "$WORKDIR"
}
trap cleanup EXIT

# 証明書チェーンを取得
echo | openssl s_client -showcerts -connect "${HOST}:${PORT}" </dev/null 2>/dev/null \
     | awk '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/' > "$CERTFILE"

# 分割
csplit -sf "$WORKDIR/cert" -b "%02d.pem" "$CERTFILE" '/-----BEGIN CERTIFICATE-----/' '{*}' > /dev/null || true

# 各証明書を表示
for cert in "$WORKDIR"/cert*.pem; do
    if [ -s "$cert" ]; then
        echo "===== $cert ====="
        openssl x509 -in "$cert" -noout -text || echo "Failed to read certificate: $cert"
        echo
    fi
done

使い方

引数にホストを指定してください。

./check_certs.sh luca.harvestasya.com

ポートを変更している場合は、ホスト名に続けてポート番号を指定してください。

./check_certs.sh rerena.harvestasya.com 7990
2
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
2
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?