LoginSignup
1
0

More than 3 years have passed since last update.

JDK8アプリケーションでの確認/Amazon S3 and Amazon CloudFront migrating service certificates to Amazon Trust Services starting March 23rd 2021.

Last updated at Posted at 2021-02-17

以下のようなメールが届きました。近くなってきたので放置せずに対応します。

Image from Gyazo


メール内に掲載されているリンク先でAWSブログ記事を読むと、

全般的に「よっぽど古くなければ大丈夫!!」というニュアンス。
弊社のアプリケーション(Java)はEC2上で動作しているので「AWSがサポートしているはずだから、最新化してれば、たぶん大丈夫かなぁ。」と思いつつも「対応を要するかどうかはアプリケーション次第」とも書かれていてモヤモヤ。

以下の証明書が全て揃っていればよい模様なので、とりあえずJavaの証明書ストアにインストールされているかをチェックしました。

必要なルート証明書

  • CN=Amazon Root CA 1,O=Amazon,C=US
  • CN=Amazon Root CA 2,O=Amazon,C=US
  • CN=Amazon Root CA 3,O=Amazon,C=US
  • CN=Amazon Root CA 4,O=Amazon,C=US
  • CN=Starfield Services Root Certificate Authority – G2,O=Starfield Technologies\, Inc.,L=Scottsdale,ST=Arizona,C=US

※各証明書はAWSのリポジトリからダウンロードできます。

確認結果

Amazon Linux(2ではない)のJava8(update 272)ではCA3とCA4がありませんでした。涙 (Amazon Linux 2には存在してました。)

# keytool -list -v -storepass changeit -keystore $JAVA_HOME/jre/lib/security/cacerts | grep amazon
別名: extra-amazonrootca1
別名: extra-amazonrootca2
★ca3がない!★
★ca4がない!★

# keytool -list -v -storepass changeit -keystore $JAVA_HOME/jre/lib/security/cacerts | grep starfield
別名: extra-starfieldrootcag2
別名: extra-starfieldservicesrootcag2
別名: starfieldclass2ca

If your tests of any of the Test URLs failed, you must update your trust store.
テストURLのいずれかのテストが失敗した場合は、トラストストアを更新する必要があります。

と書いてあるので、以下のスクリプトを使って追加しました。

lhriley/aws-cert-import.sh さんのスクリプトを改良(=KEYSTOREを変数にしただけ)させていただきました。感謝(thank you very much)。

import_amazonca.sh
#!/bin/bash -e

# create a temp dir in which to work
OLDDIR="$PWD"
TMPDIR="/tmp/_aws-ca"
KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts

mkdir "${TMPDIR}" && cd "${TMPDIR}"

AWS_CERTS=(
AmazonRootCA1.pem
AmazonRootCA2.pem
AmazonRootCA3.pem
AmazonRootCA4.pem
)

# download the bundle(s)
for cert in ${AWS_CERTS[*]}; do
    wget "https://www.amazontrust.com/repository/${cert}" -O "${TMPDIR}/${cert}"

    # extract a human-readable alias from the cert
    ALIAS=$(openssl x509 -noout -text -in "${TMPDIR}/${cert}" |
        perl -ne 'next unless /Subject:/; s/.*CN=//; print')
    echo "importing $ALIAS"
    # import the cert into the default java keystore
    keytool -import -keystore $KEYSTORE -storepass changeit -noprompt -alias "$ALIAS" -file "${TMPDIR}/${cert}"
done

# back out of the temp dir and delete the temp folder
cd "$OLDDIR"
rm -r "${TMPDIR}"

# list the imported certs as a sanity check
keytool -list -keystore $KEYSTORE -storepass changeit -noprompt | grep -i Amazon
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