zuntan02のはてなブログ

備忘録的なものです。時々職場の技術者ブログにも転記してますが、メインはこちらで。

Ubuntu 16でLet's EncryptのURLが開けなかったのでクライアント側で DST Root CA X3 を信頼済みCA一覧から削除したメモ

【問題】

環境: Ubuntu 16.04.7 LTS
でLet's encryptのサイトがcurlできない

openssl s_client -connect <相手先>:443 -servername <相手先> -showcerts -CAfile /etc/ssl/certs/ca-certificates.crt
で以下の期限切れエラー

CONNECTED(00000003)
depth=3 O = Digital Signature Trust Co., CN = DST Root CA X3
verify error:num=10:certificate has expired
notAfter=Sep 30 14:01:15 2021 GMT

【参考】

上記コマンドの説明
openssl s_client コマンドでウェブサーバーの SSL/TLS 対応状況を診断する – ラボラジアン

■対応について
https://www.walbrix.co.jp/article/openssl-102-letsencrypt-crisis.html
> 2. クライアント側で DST Root CA X3 を信頼済みCA一覧から削除する

→編集と反映方法
https://qiita.com/msi/items/9cb90271836386dafce3

【具体的にどうするの?】

以下のようにして無効化して反映した

# バックアップ
cp -p /etc/ca-certificates.conf /etc/ca-certificates.conf.bak

# /etc/ca-certificates.confでDST_Root_CA_X3.crtを無効化

diff /etc/ca-certificates.conf /etc/ca-certificates.conf.bak
< !mozilla/DST_Root_CA_X3.crt
---
> mozilla/DST_Root_CA_X3.crt

# 反映
update-ca-certificates

→いけた

Ubuntu(WSL2の)でgit cloneしたらserver certificate verification failed

【概要】

Ubuntu/WSL2でgit cloneしたらけられた

fatal: unable to access 'https://ほげほげ': server certificate verification failed. CAfile: none CRLfile: none

【解決に至るメモ】

メッセージによれば証明書ファイルがないとのことなのでインストール

apt-get install --reinstall ca-certificates

→エラー

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://cli-assets.heroku.com/apt ./ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <PUBKEY>

ググるとこのPUBKEYを取得しないといけないらしい

sudo  apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv <PUBKEY>
===
Executing: /tmp/apt-key-gpghome.zCUNU82Zet/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv <PUBKEY>
gpg: key <PUBKEY>: public key "Heroku Inc. <support@heroku.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
===

再度証明書をインストール

apt-get install --reinstall ca-certificates

これでgit cloneできたよ

【メモ】Auth0のログをCloudwatchに飛ばすExtensionが利用できなくなったのでイベントブリッジ経由に変更した

【経緯】

Auth0のExtensionで「Logs to CloudWatch」を使っていたのだけど、新しいテナントで利用しようと思ったら検索結果に出てこない。
https://auth0.com/docs/troubleshoot/product-lifecycle/deprecations-and-migrations/migrate-from-log-extensions
によれば、

2022年11月2日に、次のAuth0ログ拡張機能は非推奨になります。
(略)
2022年5月4日以降、上記のリストから新しい拡張機能を作成することはできなくなります。
Auth0マーケットプレイスで利用可能なAmazonEventBridge統合をセットアップします。
イベントバスでイベントが利用可能になったら、それらのイベントをAWSCloudWatchにマッピングするルールを作成します。
(機械翻訳)

ってなってて、ログストリーム作ってAmazonEventBridge経由でCloudwatchに流すことになる模様。

【やってみた】

1)Amazon EventBridge Integration を Auth0 Marketplace で検索して追加します

[Marketplace]-[Amazon EventBridge]-[Add Integration]

[Monitoring]-[Streams]で追加されたAMazonEventBridgeを設定する

Create Event Stream
Name:てきとうな名前

AWS Account ID 
AWSアカウントIDいれる

AWS Region
Asia Pacific(Tokyo)

※このときError!Your current subscription plan does not support log streams
 とか出た場合はアカウントをフリープランから有償プランに切り替えてから。

2)パートナーイベントソース確認

AWSマネージドコンソールにて
[Amazon EventBridge]-[パートナーイベントソース]を確認
> aws.partner/auth0.com/(略)/auth0.logs
が表示されていることを確認

3)イベントバスとの関連付け

上記イベントソースを選択して[イベントバスと関連付ける]を選択
特に設定は変更せずそのまま[関連付ける]を押下

4)EventBridgeでルールを作成

[Amazon EventBridge]-[イベント]-[ルール]-[ルールを作成]

ステップ 1 ルールの詳細を定義

名前 auth0など適当に
説明 任意
イベントバス 先ほど関連付けたイベントバス(aws.partner/auth0.com/(略)/auth0.logs)を選択
ルールタイプ イベントパターンを持つルール(デフォルト)
で[次へ]

ステップ 2 イベントパターンを構築

イベントパターンで
イベントソース:EventBridge パートナー
パートナー:Auth0
イベントタイプ:すべてのイベント
を選択

ステップ 3 ターゲットを選択

ターゲットタイプ:AWSのサービス・CloudWatchロググループ
ロググループ:/aws/events/Auth0(あらかじめ作っておく)

で[ルールの作成]


確認

ログをはいてみる→どんどんたまっていく。OK

メモ:AWS CodeCommitのユーザー作成

【参考URL】
https://proglearn.com/2019/12/27/%E3%80%90aws%E3%80%91codecommit%E7%94%A8%E3%81%AEiam%E3%83%A6%E3%83%BC%E3%82%B6%E3%82%92%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B%E6%89%8B%E9%A0%86/

IAM作ってポリシーでAWSCodeCommitFullAccess追加して
AWS CodeCommit の HTTPS Git 認証情報を付与すればよい模様

f:id:zuntan02:20220311142320p:plain
■料金について
最初の5人まで無料、6人目から$1/人月

https://aws.amazon.com/jp/codecommit/pricing/
曰く
> お客様のアカウントで、ある月のアクティブユーザー数が 6 人である場合、追加料金または超過料金がないとすると、1 USD が請求されます。

【備忘】シェルの変数に乗せたパスワードがエスケープされてた

AUTH_PASSWORD="hoge$fuga&hoge"

echo $AUTH_PASSWORD
hoge&hoge

【原因】
下記記事より

bashでは下記の文字が特殊な意味を持ちます。
; & ( ) | ^ < > ? * [ ] $ ` ' " \ ! { } 改行 タブ スペース
これらの特殊な意味を打ち消して普通の文字として扱うことをエスケープといいます。

\   直後の1文字をエスケープ
''  シングルクォーテーションで囲まれた文字列は普通の文字
""  ダブルクォーテーションで囲まれた文字列は $ ` \ 以外の文字はエスケープする
    ""内の\は、\の直後に $ ` \ がある場合のみエスケープする

【参考】
anmino.hatenadiary.org

スピーカーのエッジ修理した

【経緯】
スピーカーエッジの修理パーツというのを売っていたのでついカッとなって買ってしまった
https://amzn.to/3pGswt2

f:id:zuntan02:20220223202657j:plain
こんな感じのが届いた

【やったこと】
これを

f:id:zuntan02:20220223182254j:plain
エッジの腐ったスピーカー

こうして

f:id:zuntan02:20220223201808j:plain
ウレタンの腐ってるところを掃除する

こうじゃ

f:id:zuntan02:20220224105102j:plain
なんとなく直った気がする

CentOS6.5+php5.xでHTTP/2へのリクエストをする(cURLモジュールの更新)

■概要

タイトルの通り。
CentOS6.5で

curl --http2 -v https://http2bin.org/get

ができないためバージョンを上げたい。

curl -V
curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

【問題】

  • nghttp2が有効になっていない
  • CentOS6のvaultリポジトリでもcurlの最新は7.19.7-54.el6_10。今回7.33以上が必須となる

上記のため、ソースコードよりコンパイルする
cURLの最新版はこの時点で7.81だったが、対象環境(CentOS6)ではコンパイルが通らなかったため、他環境で実績のあった7.58を利用した。

えっ……いろいろ言いたいことがあるのは理解しますがワークアラウンドとして。

■作業概要

# nghttp2インストール
yum install nghttp2 libnghttp2 libnghttp2-devel

# cURL7.58コンパイル
cd /usr/local/src/
wget --no-check-certificate https://curl.haxx.se/download/curl-7.58.0.tar.gz
tar xzvf curl-7.58.0.tar.gz
cd curl-7.58.0
./configure --prefix=/usr/local --with-ssl --enable-libcurl-option --with-nghttp2

# =====
#   curl version:     7.58.0
#   Host setup:       x86_64-pc-linux-gnu
#   Install prefix:   /usr/local
#   Compiler:         gcc
#   SSL support:      enabled (OpenSSL)
#   SSH support:      no      (--with-libssh2)
#   zlib support:     enabled
#   brotli support:   no      (--with-brotli)
#   GSS-API support:  no      (--with-gssapi)
#   TLS-SRP support:  no      (--enable-tls-srp)
#   resolver:         POSIX threaded
#   IPv6 support:     enabled
#   Unix sockets support: enabled
#   IDN support:      no      (--with-{libidn2,winidn})
#   Build libcurl:    Shared=yes, Static=yes
#   Built-in manual:  enabled
#   --libcurl option: enabled (--disable-libcurl-option)
#   Verbose errors:   enabled (--disable-verbose)
#   SSPI support:     no      (--enable-sspi)
#   ca cert bundle:   /etc/pki/tls/certs/ca-bundle.crt
#   ca cert path:     no
#   ca fallback:      no
#   LDAP support:     no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
#   LDAPS support:    no      (--enable-ldaps)
#   RTSP support:     enabled
#   RTMP support:     no      (--with-librtmp)
#   metalink support: no      (--with-libmetalink)
#   PSL support:      no      (libpsl not found)
#   HTTP2 support:    enabled (nghttp2)
#   Protocols:        DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP
# =====

make
make install

curl -V
# curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.0.1e zlib/1.2.3 nghttp2/1.6.0
# Release-Date: 2018-01-24
# Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
# Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy

# 確認
curl --http2 -v https://http2bin.org/get

# phpのモジュール確認
php -i | grep cURL
# cURL support => enabled
# cURL Information => 7.19.7
# この時点では古いまま

# インストールされたusr/local/lib以下にldconfigでライブラリのパスを通す
echo '/usr/local/lib' > /etc/ld.so.conf.d/custom-libs.conf
ldconfig

# 確認
ldconfig -p | grep curl


# phpのモジュール再確認
php -i | grep cURL
# cURL support => enabled
# cURL Information => 7.58.0

OK

■備考

yumもvaultが使えなくなっていて困った。別途記載します
zuntan02.hateblo.jp