Let's Encryptで複数ドメインのECC証明書が機能しませんでした

証明書の更新を開始するにはどうすればよいですか。/shared/ssl から古い証明書を削除するだけでよいですか?

再構築されると常にそうなると思うので、何も削除する必要はありません。

「いいね!」 1

証明書は昨日発行されたため、通常はLEスクリプトで--forceが必要です。古い証明書の名前を変更し、再構築をテストしています。

このドメインは機能していないようです。入力された2番目のドメインが取得されません: https://ssl-tools.net/webservers/rpg-foren.com

また、すべてが正しく置き換えられていないようです。eccファイルにはサブドメインがありません:

cat /etc/runit/1.d/letsencrypt
#!/bin/bash
/usr/sbin/nginx -c /etc/nginx/letsencrypt.conf

issue_cert() {
  LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --issue $2 -d rpg-foren.com -d www.rpg-foren.com --keylength $1 -w /var/www/discourse/public
}

cert_exists() {
  [[ "$(cd /shared/letsencrypt/rpg-foren.com$1 && openssl verify -CAfile <(openssl x509 -in ca.cer) fullchain.cer | grep "OK")"]]
}

########################################################
# RSA cert
########################################################
issue_cert "4096"

if ! cert_exists ""; then
  # Try to issue the cert again if something goes wrong
  issue_cert "4096" "--force"
fi

LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh \
  --installcert \
  -d rpg-foren.com \
  -d www.rpg-foren.com --fullchainpath /shared/ssl/rpg-foren.com.cer \
  --keypath /shared/ssl/rpg-foren.com.key \
  --reloadcmd "sv reload nginx"

########################################################
# ECDSA cert
########################################################
issue_cert "ec-256"

if ! cert_exists "_ecc"; then
  # Try to issue the cert again if something goes wrong
  issue_cert "ec-256" "--force"
fi

LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh \
  --installcert --ecc \
  -d rpg-foren.com \
  --fullchainpath /shared/ssl/rpg-foren.com_ecc.cer \
  --keypath /shared/ssl/rpg-foren.com_ecc.key \
  --reloadcmd "sv reload nginx"

if cert_exists "" || cert_exists "_ecc"; then
  grep -q 'force_https' "/var/www/discourse/config/discourse.conf" || echo "force_https = 'true'" >> "/var/www/discourse/config/discourse.conf"
fi

/usr/sbin/nginx -c /etc/nginx/letsencrypt.conf -s stop

私はちょうど手動で以下を実行しました。これで証明書が適合します:

/shared/letsencrypt/acme.sh --issue --force -d rpg-foren.com -d www.rpg-foren.com --keylength 4096 -w /var/www/discourse/public --server letsencrypt
/shared/letsencrypt/acme.sh --issue --force -d rpg-foren.com -d www.rpg-foren.com --keylength ec-256 -w /var/www/discourse/public --server letsencrypt

/shared/letsencrypt/acme.sh --installcert -d rpg-foren.com -d www.rpg-foren.com --fullchainpath /shared/ssl/rpg-foren.com.cer --keypath /shared/ssl/rpg-foren.com.key --reloadcmd "sv reload nginx"
/shared/letsencrypt/acme.sh --installcert -d rpg-foren.com -d www.rpg-foren.com --fullchainpath /shared/ssl/rpg-foren.com_ecc.cer --keypath /shared/ssl/rpg-foren.com_ecc.key --reloadcmd "sv reload nginx"

これは私のリダイレクト用のリライトです:

   # tell letsencrypt what additional certs to get
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--keylength/
        to: "-d www.rpg-foren.com --keylength"
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--fullchainpath/
        to: "-d www.rpg-foren.com --fullchainpath"
    - file:
        path: /etc/nginx/conf.d/discourse_redirect.conf
        contents: |
          server {
            listen 80;
            listen 443 ssl;
            server_name www.rpg-foren.com;
            return 301 $scheme://rpg-foren.com$request_uri;

            ssl_protocols TLSv1.2 TLSv1.3;
            ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
            ssl_prefer_server_ciphers off;

            ssl_certificate /shared/ssl/rpg-foren.com.cer;
            ssl_certificate /shared/ssl/rpg-foren.com_ecc.cer;

            ssl_certificate_key /shared/ssl/rpg-foren.com.key;
            ssl_certificate_key /shared/ssl/rpg-foren.com_ecc.key;

            ssl_session_tickets off;
            ssl_session_timeout 1d;
            ssl_session_cache shared:SSL:1m;
          }

replaceコマンドは一度しか実行されない可能性がありますか?

証明書は現在有効なようですね。

リダイレクトはチェーンのどこかで処理されているはずなので、それが機能するために何もする必要はないと思います。おそらく、その部分をymlファイルから削除した方が良いでしょう。

期待どおりに動作しているようです。

はい、ただし、フック経由ではなく手動で設定しました。フックが正しく機能しなかったためです。

wwwサブドメインからメインドメインへのリダイレクトのことですか?少なくともnginxではそうではありません。URLは定義されておらず、ウェブサーバーはすべての着信ドメインに応答します。

.
私の方では機能しています(下記参照)。

サイトに解決されるものはすべてホスト名にリダイレクトされるということです。標準的なインストールであれば、IPアドレスを入力するとhttps://hostnameにリダイレクトされます。(下記参照)

これは、https://dashboard.literatecomputing.com/ で新しい標準インストールを作成し、さらに上記のdomain2フィールドにextrahostname.myforum.usを貼り付け、結果のafter_sslフックをweb_only.ymlhooks:の直後にコピー&ペーストして(スクリプトがデータコンテナを構築中に実行したので、初回終了後に再構築する必要はありませんでした!)設定したばかりです。

これらはすべて期待どおりに機能します。

「いいね!」 1

サブドメインは、rsa および ecc の両方のインストール スクリプトで /etc/runit/1.d/letsencrypt に格納されるということですか?
上記でわかるように、フックは rsa 部分にのみサブドメインを格納しましたが、ecc 部分には格納しませんでした。

  --installcert \
  -d rpg-foren.com \
  -d www.rpg-foren.com
  --installcert --ecc \
  -d rpg-foren.com \
  --fullchainpath

/etc/runit/1.d/letsencrypt は以下の通りです。

#!/bin/bash
/usr/sbin/nginx -c /etc/nginx/letsencrypt.conf

issue_cert() {
  LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --issue $2 -d test.myforum.us -d extrahostname.myforum.us --keylength $1 -w /var/www/discourse/public
}

cert_exists() {
  [[ "$(cd /shared/letsencrypt/test.myforum.us$1 && openssl verify -CAfile <(openssl x509 -in ca.cer) fullchain.cer | grep "OK")" ]]
}

########################################################
# RSA cert
########################################################
issue_cert "4096"

if ! cert_exists ""; then
  # Try to issue the cert again if something goes wrong
  issue_cert "4096" "--force"
fi

LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh \
  --installcert \
  -d test.myforum.us \
  -d extrahostname.myforum.us  --fullchainpath /shared/ssl/test.myforum.us.cer \
  --keypath /shared/ssl/test.myforum.us.key \
  --reloadcmd "sv reload nginx"

########################################################
# ECDSA cert
########################################################
issue_cert "ec-256"

if ! cert_exists "_ecc"; then
  # Try to issue the cert again if something goes wrong
  issue_cert "ec-256" "--force"
fi

LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh \
  --installcert --ecc \
  -d test.myforum.us \
  --fullchainpath /shared/ssl/test.myforum.us_ecc.cer \
  --keypath /shared/ssl/test.myforum.us_ecc.key \
  --reloadcmd "sv reload nginx"

if cert_exists "" || cert_exists "_ecc"; then
  grep -q 'force_https' "/var/www/discourse/config/discourse.conf" || echo "force_https = 'true'" >> "/var/www/discourse/config/discourse.conf"
fi

/usr/sbin/nginx -c /etc/nginx/letsencrypt.conf -s stop

ああ。RSA(悪い)証明書にはありますが、ECC(良い)証明書にはないことがわかりました。

わかりました。その --fullcert のスタンザには global: true が必要です。現在テスト中です。

「いいね!」 2

OK. Here’s the new ‘/etc/runit/1.d/letsencrypt’

#!/bin/bash
/usr/sbin/nginx -c /etc/nginx/letsencrypt.conf

issue_cert() {
  LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --issue $2 -d test.myforum.us -d extrahostname.myforum.us --keylength $1 -w /var/www/discourse/public
}

cert_exists() {
  [[ "$(cd /shared/letsencrypt/test.myforum.us$1 && openssl verify -CAfile <(openssl x509 -in ca.cer) fullchain.cer | grep "OK")" ]]
}

########################################################
# RSA cert
########################################################
issue_cert "4096"

if ! cert_exists ""; then
  # Try to issue the cert again if something goes wrong
  issue_cert "4096" "--force"
fi

LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh \
  --installcert \
  -d test.myforum.us \
  -d extrahostname.myforum.us  --fullchainpath /shared/ssl/test.myforum.us.cer \
  --keypath /shared/ssl/test.myforum.us.key \
  --reloadcmd "sv reload nginx"

########################################################
# ECDSA cert
########################################################
issue_cert "ec-256"

if ! cert_exists "_ecc"; then
  # Try to issue the cert again if something goes wrong
  issue_cert "ec-256" "--force"
fi

LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh \
  --installcert --ecc \
  -d test.myforum.us \
  -d extrahostname.myforum.us  --fullchainpath /shared/ssl/test.myforum.us_ecc.cer \
  --keypath /shared/ssl/test.myforum.us_ecc.key \
  --reloadcmd "sv reload nginx"

if cert_exists "" || cert_exists "_ecc"; then
  grep -q 'force_https' "/var/www/discourse/config/discourse.conf" || echo "force_https = 'true'" >> "/var/www/discourse/config/discourse.conf"
fi

/usr/sbin/nginx -c /etc/nginx/letsencrypt.conf -s stop
~
~

and now I have this, which looks good? https://ssl-tools.net/webservers/extrahostname.myforum.us

Does that look right? If so, I’ll edit the OP to include the global directive.

「いいね!」 2

私のアイデア:

    # letsencryptに追加の証明書を取得するように指示する
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--keylength/
        to: "-d www.rpg-foren.com --keylength"
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--installcert \//
        to:  |
          --installcert \
          -d www.rpg-foren.com
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--installcert --ecc \//
        to:  |
          --installcert --ecc \
          -d www.rpg-foren.com

私のものは機能しませんか? コード行数が3分の1少なくなっています。

書き直しが見当たらないのですが、それとも何か見落としていますか?
ファイルをきれいにしたかっただけです^^

まだやっていません。それが機能したかどうかを確認するのを待っていました。

変更点は、2番目の replace: の末尾に global: true を追加しただけです。

    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--fullchainpath/
        to: "-d =domain2=  --fullchainpath"
        global: true

そして、全体は以下のようになります。

  after_ssl:
   # tell letsencrypt what additional certs to get
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--keylength/
        to: "-d extrahostname.myforum.us --keylength"
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--fullchainpath/
        to: "-d extrahostname.myforum.us  --fullchainpath"
        global: true


「いいね!」 1

複数の置換にはグローバルがパラメータになります。

投稿されたファイルを見る限り問題なさそうです。まだ試していませんが。

はい。以前お話しされていたことを理解するのに十分注意を払っていなかったことをお詫びします。私の(悪い)テストでは「機能しました」が、気づかず、ec-whatever証明書が実際にあるかどうかを確認する方法もわかりません。粘り強くいてくれてありがとうございます。

https://ssl-tools.net/webservers/extrahostname.myforum.us は、それが正しいものを持っているように見せますか?

OPを編集したので、試して、上のフォームからコピー&ペーストできます。

テストサイトで自分でテストしたい場合、SSHキーを送っていただければ、私がセットアップしたばかりのサイトへのアクセスを提供します。その後、そこで独自のテストドメインを使用してクリーンインストールできます。または、本番サイトでそのまま実行して、最善を祈ることもできます。 :person_shrugging:

ここにあります。

ls -la /var/discourse/shared/standalone/ssl/
total 24
drwxr-xr-x  2 root root 4096 Sep 24 13:02 .
drwxr-xr-x 15 root root 4096 Sep 23 18:31 ..
-rw-r--r--  1 root root 3941 Sep 25 07:43 rpg-foren.com.cer
-rw-r--r--  1 root root 3941 Sep 25 07:43 rpg-foren.com_ecc.cer
-rw-------  1 root root 3243 Sep 25 07:43 rpg-foren.com_ecc.key
-rw-------  1 root root 3243 Sep 25 07:43 rpg-foren.com.key

問題は、ecc と rsa を個別にテストする方法がわからないことです。
作成ファイルが現在適合しているため、これ以上のテストは必要ありません。

「いいね!」 1
root@test-web-only:/shared/ssl# ls -l
total 16
-rw-r--r-- 1 root root 3953 Sep 25 16:41 test.myforum.us.cer
-rw-r--r-- 1 root root 2877 Sep 25 16:41 test.myforum.us_ecc.cer
-rw------- 1 root root  227 Sep 25 16:41 test.myforum.us_ecc.key
-rw------- 1 root root 3247 Sep 25 16:41 test.myforum.us.key

これで問題なさそうですね。解決したと思われますので、この件は新しいトピックに移したいと思います。

「いいね!」 1

証明書は次のようにテストできます。

openssl x509 -in /var/discourse/shared/standalone/ssl/test.myforum.us.cer -noout -text
次に、ドメインが dns の下にリストされているはずです。
DNS:rpg-foren.com, DNS:www.rpg-foren.com

「いいね!」 1
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            03:f8:b5:6a:e0:97:53:7f:22:33:81:22:35:b4:3f:73:75:7f
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = US, O = Let's Encrypt, CN = R10
        Validity
            Not Before: Sep 25 14:57:13 2024 GMT
            Not After : Dec 24 14:57:12 2024 GMT
        Subject: CN = test.myforum.us
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (4096 bit)
                Modulus:
                    00:be:a3:9b:79:78:dd:8f:e2:8f:28:f0:d9:6c:74:
...                    b0:84:33
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment
            X509v3 Extended Key Usage:
                TLS Web Server Authentication, TLS Web Client Authentication
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Subject Key Identifier:
                43:55:B7:D6:54:03:CE:B0:FB:C8:D1:2A:42:F5:B7:C5:60:C7:D8:48
            X509v3 Authority Key Identifier:
                BB:BC:C3:47:A5:E4:BC:A9:C6:C3:A4:72:0C:10:8D:A2:35:E1:C8:E8
            Authority Information Access:
                OCSP - URI:http://r10.o.lencr.org
                CA Issuers - URI:http://r10.i.lencr.org/
            X509v3 Subject Alternative Name:
                DNS:extrahostname.myforum.us, DNS:test.myforum.us
            X509v3 Certificate Policies:
                Policy: 2.23.140.1.2.1
            CT Precertificate SCTs:
                Signed Certificate Timestamp:
                    Version   : v1 (0x0)
                    Log ID    : DF:E1:56:EB:AA:05:AF:B5:9C:0F:86:71:8D:A8:C0:32:
                                4E:AE:56:D9:6E:A7:F5:A5:6A:01:D1:C1:3B:BE:52:5C
                    Timestamp : Sep 25 15:55:44.143 2024 GMT
                    Extensions: none
                    Signature : ecdsa-with-SHA256
                    Signed Certificate Timestamp:
                    Version   : v1 (0x0)
                    Log ID    : A2:E3:0A:E4:45:EF:BD:AD:9B:7E:38:ED:47:67:77:53:
                                D7:82:5B:84:94:D7:2B:5E:1B:2C:C4:B9:50:A4:47:E7
                    Timestamp : Sep 25 15:55:45.945 2024 GMT
                    Extensions: none
                    Signature : ecdsa-with-SHA256
    Signature Algorithm: sha256WithRSAEncryption
    Signature Value:
        cf:c6:59:d8

and that includes:

            X509v3 Subject Alternative Name:
                DNS:extrahostname.myforum.us, DNS:test.myforum.us

Ah. OK.

openssl x509 -in /var/discourse/shared/web-only/ssl/test.myforum.us_ecc.cer -noout -text

contains:

            X509v3 Subject Alternative Name:
                DNS:extrahostname.myforum.us, DNS:test.myforum.us
「いいね!」 1