2020/10,江端さんの忘備録

私が、当初、夫婦別姓制度に反対の立場であったことは、これまで何度もお話してきたと思います。

I think I have told you many times in the past that I was initially opposed to the "conjugal surname system".

同性愛を、精神障害の一態様であるとすら思っていたこともあります。

I once even thought of homosexuality as a form of mental disorder.

今は、そうは思っていません。

Now, I don't think so.

「自分で勉強したから」と言いたいですが、基本的には、「社会の意識の変化に身を委ねてきた」という面が強いです。

I'd like to say "because I learned it myself," however, essentially, I've surrendered myself to the changing attitudes of society.

とはいえ、『多くの人が肯定していれば、多分正しいのだろう』という考え方はリスクがあります。

Nevertheless, the idea that "if a lot of people affirm it, it's probably right" is risky.

しかし、『多くの人が関心を持っているのであれば、ちゃんと自分で調べてみよう』というスタンスなら、良いと思います。

However, if your stance is "if it's the matter that many people are interested in, I'll look into it myself". Then it's good.

-----

新しい考え方(夫婦別姓、同性愛等)を自分に取り込むには、私には結構なエネルギーが必要でした。

It took quite a bit of energy to incorporate new ideas (marital separation, homosexuality, etc.) into my life.

自分の中にある、他の部分の考え方の変更も余儀なくされるからです ―― 正直、これは、「辛い作業」です。

Because it also forces me to change the way of other parts of myself. Honestly, this is "hard work".

特に、既存の価値観で生きてきたシニアにとっては、若い人には想像できないほどの「痛みを伴う」作業なのです。

It's a "painful" process that is unimaginable to younger people, especially for elder people who have lived by existing values.

「痛くて辛い作業」ですので、他人に強要することはできません。

It's "painful work" and I can't force others to do it.

しかし、その「痛くて辛い作業」を経ないと、現状の制度や差別で痛み苦しんでいる人 ―― 私の痛みや辛さとは比較にならない程の ―― に寄り添うことができません。

However, without going through that "painful work," it is impossible to reach out to those who are in pain and suffering from the current system and discrimination. It's so much worse than my pain and hardship.

-----

しかし、基本的には、それは「他人の苦痛」であって、「自分の苦痛」ではありません。

But basically, it's "other people's pain" and not "my pain".

どれほどの痛みや苦しみがあろうが ―― 所詮は、「他人事」です。

No matter how much pain and suffering there is -- it's just for "other people".

あなたは、それを無視したっていいと思います。

You're allowed to ignore it.

私(だけ)は、あなたを責めません。

I (only) don't blame you.

私も、沢山の問題を「無視」し続けています。

I also continue to "ignore" a lot of issues.

私のやっていることは、単なる「問題の数値化」に過ぎません。問題の解決法(ソリューション)に至れているものはほとんどありません。

What I am doing is merely "quantifying the problem". Very few of the problems (solutions) have been reached.

(続く)

(To be continued)

2020/10,江端さんの忘備録

(昨日の続きです)

(Continuation from yesterday)

しかし、一方の私は、「完全な死」など希望していません。

But I, on the other hand, have no hope of "complete death".

■理性的な思考が残存しており、

- Reasonable thinking remains,

■自分の意志が第三者に伝達可能で、

- Being able to convey my intentions to a third party

■自分の肉体が可制御の状態にあって、

- My body is in control

■絶望的な苦痛が到来する前に

- Before the arrival of desperate pain

とっとと死んでしまいたい、という気持ちがあります。

I have a feeling that I want to die suddenly.

私は、苦痛回避の死を肯定し、そして、他者にも実施してきました。

I have affirmed the death of pain avoidance and have done it to others.

「いかなる手を尽しても、絶対的に救えない、究極の死」などというのは ―― 本当に、冗談ではありません。勘弁して下さい、と、全力で土下座できるレベルです。

"The ultimate death that I can never save no matter what I do" is not joking. I can kneel down on the ground with saying "Please forgive me "

-----

私が何を言いたいかというと、

What I want to say, is that

『あらゆる手を尽くして延命を施すという考え方』は、昨日の「江端の腕時計」の話と似ていないか

Isn't "the idea of doing everything possible to prolong life" similar to the story of "Ebata's watch"?

ということです。

私の命を制御する側 ―― 例えば

The side that controls my life, for example

■「医師」の立場からすると、命を可能な限り延すことが「職務」であり、

- From the point of view of a "doctor", it is the "duty" to prolong life as much as possible.

■「身内」の立場からすると、命を可能な限り延すことが「権利」である

- From the standpoint of "relatives", it is "right" to prolong life as much as possible.

かのように思えるかもしれない、ということです。

might think this problem as above.

言い換えるのであれば、

In other words, that means,

『私の腕時計は、耐用年数を越えて、すでに廃棄される状態にある』

"My watch has reached the end of its useful life and is already in a state of disposal."

にもかからわず、

however,

『腕時計の意志を無視して、性能劣化している状態で、見苦しい外観を晒され続け、所有者によって動かされて続けられている』

"Ignoring the will of the watch, it continues to be exposed to its unsightly appearance and kept being driven by the owner, with its performance degraded."

ということです。

-----

『腕時計と人命を同じロジックで説明するのは乱暴に過ぎる』と思う人はいるかもしれません。

Some may think that it is too rough to explain a wristwatch and human life with the same logic.

法律や生命倫理、あるいは、その時点の社会通念や常識など、様々な問題を総合的に考えなければならないことは分かっています。

We know that we have to think comprehensively about various issues such as law, bioethics, and social conventions and common sense at that time.

しかし、私は、この問題、一度、ここまで単純化して考えてみる必要があると思っています。

However, I think this problem needs to be simplified to this point once.

―― 私達は、「腕時計の使用者」であると同時に、「腕時計本体」でもあるのです。

We are not only "watch users" but also "watch bodies".

2020/10,江端さんの忘備録

私が愛用している時計は、こちらに記載したものです。

This is about my watch repair.

耐用年数をとうに越えており、すでに同じ時計は入手できませんが、電池交換を繰り返しながら、使い続けています。

It's already past its service life and the same watch is no longer available. However I continue to use it, changing the batteries repeatedly.

リストバンドはジョイント部が欠けており、もはやリストバンドの交換もできない状況です。

The wristband is missing a joint and the wristband can no longer be replaced.

ですので

So,

―― Amazonで購入したリストバンドを、瞬間接着剤で、強制的にジョイント

"I buy a wristband from Amazon, with instant glue, to force a joint"

しています。

リストバンドが劣化して、切断した場合には、その接続の部分を無理矢理引き剥がして、固化した接着剤をドライバで削ぎ取っています。

If the wristband deteriorates and is cut, the connection part is forcibly peeled off and the solidified adhesive is scraped off with a screwdriver.

案外なんとかなるものです。

It's surprisingly manageable.

時計に限らず、私は、"モノを直して使い続ける"のが好きです。

Besides watches, I like to "fix things and keep using them."

-----

デバイスを完全に停止するまで使い倒す ―― これは、あまり経済的な行為とは言えません。

"Use it until the device is completely shut down". This is not very economical.

国内消費にも、GDPにも貢献しません。

It does not contribute to domestic consumption or GDP.

私自身「既存システムの積極的な廃棄」をアジテーションしてきた、という自覚すらあります。

I even realize that I have agitated "active disposal of existing systems".

そんな私が『モノを大切にしましょう』などと、おこがましいことが言える立場ではありません。

I'm not in a position to say something, such as "Let's take good care of things."

私は、デバイスの「完全な死」を見届けたいだけです。

I just want to see the "complete death" of the device.

私がいかなる手を尽しても、絶対的に救えない、究極の死を。

The ultimate death that I can never save no matter what I do.

(続く)

2020/10,江端さんの忘備録

最近、NHKの「ドキュメント72時間」を見ています。

Recently, I've been watching NHK's "documentary series 72 Hours".

ある一定の場所で、72時間、市井の人々の取材を放送する番組です。

It is a program that broadcasts 72 hours of coverage of the people of the city in a certain location.

■NHKスペシャルのように、『聞き漏らさずに視聴しなければ』というような緊張間もなく、

There's no need to be tense like the NHK specials, where I have to watch it without missing a beat.

■他の民放番組のように、特異な行動や言動をする人を、面白可笑しく編集するでもなく(自分の街をインタビューされたシーンは、かなり不快だった)

It's not like other commercial TV shows that edit out people who act and behave in a peculiar way for fun or funny.(The scene where they interviewed someone from my town was quite uncomfortable.)

肩の力を抜いて見られるので、結構気にいっています。

I like it a lot because I can relax to watch it.

もっとも、この「ドキュメント72時間」にしても、市井の人々の「いい感じのコメント」や「琴線にふれるコメント」だけを集めている、という感は否めません。

However, it cannot be denied that this "documentary series 72 Hours" is a collection of "good comments" and "heartful comments" from the people.

しかし、番組として構成する以上、それは仕方のないことです。

But as long as it's structured as a program, I think that it cannot be helped.

-----

先日、嫁さんと2人で、夕食を食べながら、「東京・隅田川 花火のない静かな夏に」を見ていました。

The other day, my wife and I were watching "Tokyo Sumida River, Quiet Summer without Fireworks" while eating dinner.

そこでは、「一旗上げようと東京にやって来て」「それが叶わずに今に至る」という高齢者の方のインタビューシーンが出てきました。

There was an interview scene with an elderly man who said that "he came to Tokyo to make a name for himself", and "he couldn't do it".

先日の日記にも記載したのですが、

I mentioned it in my diary the other day.

―― "一旗"って何だろう?

"What does "the flag" mean?"

と、ずっと考えています。

I keep thinking about it.

-----

江端:「『東京に出てくれば、何かチャンスがある』という発想が良く分からん。そもそも、東京に、語るほどのメリットがあるのか?」

Ebata: "I don't understand the idea that "there are opportunities if you come to Tokyo". In the first place, are there any advantages to Tokyo that are worth talking about?

嫁さん:「大学の数、仕事の数、出会う人間の数、娯楽の数、手に入れられる情報とその速度、その他もろもろ違うでしょう」

Wife: "The number of colleges, jobs, people you meet, entertainments, and the information you can get and the speed at which you can get it, and everything else will be different"

江端:「まあ、私の場合、ネットと通販があれば、十分に足るけど ―― まあ、その通りかなぁ。特に「人脈」については、都会は圧倒的に有利かもしれない」

Ebata: "Well, in my case, the internet and mail order are enough for me. However, I guess you're right. Especially when it comes to "networking", the city may have a huge advantage.

嫁さん:「まあ、パパの場合は『人間嫌い』だから、そのメリットはないと思うけど」

Wife: "Well, in your case, I don't think you have the benefit of that because you are a misanthrope.

(続く)

(To be continued)

2020/10,江端さんの忘備録

本日、東京証券取引所のシステムがダウンしました。

Today, the Tokyo Stock Exchange system is down.

原因については不明ですが、システムエンジニアとして申し上げることができるとしたら、

I'm not sure what caused this, but as a systems engineer, if I could offer something to you, it would be

――『各期、連休等の初日と最終日は、システムは停止するものと考えておくこと』が肝要

"It is essential to assume that the system will be shut down on the first and last day of each term, consecutive holidays, etc."

ということです。

システム保守や、システムリプレースは、期末に行われ、その起動は期の初日に行われることがあるからです。

This is because system maintenance and system replacement may take place at the end of the period, and its launch may take place on the first day of the period.

どんなに事前にチェックしても、「テスト環境」と「運用環境」は違います。

No matter how much you check in advance, there is a difference between a "test environment" and an "operational environment".

現実世界の、全ての状況を想定したテストというのは、夢物語です。

Testing for all situations is just a dream.

どんなシステムも、基本的には「ダウン」する運命にあるのです。

Any system is essentially doomed to go "down".

で、その「ダウン」のポテンシャルが最大化するのが、「各期や連休等の初日と最終日」ということです。

And that "down" potential is maximized on the first and last day of each period, holiday, etc.

-----

ところで、システムを様々なシナリオで攻撃することで、製品の弱点を見つけ出す役割の人を「テスター」と言います。

By the way, the person responsible for finding weaknesses in a product by attacking the system in various scenarios is called a "tester".

米国赴任中に、私、テスター用のプログラムを作り、各種の攻撃を仕掛け続けていたのですが、

While I was stationed in the U.S., I wrote a program for our testers that kept launching all sorts of attacks.

―― なんとなく、チームメンバから嫌な顔をされていました。

"Somehow, I was getting a bad look from my team members"

特に、開発者は、私がパーティションに顔を出すだけで、「あの日本人が、また来た」という顔をしていたように思います。

In particular, the developers seemed to get that "that Japanese guy is here again" look on their faces when I just showed up at the partition.

無理はありません。

It's reasonable.

そりゃ、作ったばかりのコードは、自分の創作物であり、自分の子どもです。

That's because the code they just created is their own creation and their own child.

それを、いきなり「苛められる」のですから、愉快であろうはずがありません。

It can't be pleasant because they are suddenly "tortured".

-----

逆に、私が作った開発物を、他のテスターによって攻撃されることがありましたが ―― 私も不快でした。

On the other hand, there have been times when I've been attacked by other testers on developments I've made -- and I've been uncomfortable, too.

それが、仕事であることは分かっていても、です。

Even though I know it's just a work.

そんな日は、『ダウンの再現条件を、ちゃんとスペックアウトしてこいよ!』などと愚痴を言いながら、強い酒を飲んでいました。

On a day like that, I said that "spec out the conditions for reproducing down" and I was drinking with complaining about such things.

まあ、仕事というのものは、理不尽なものである、ということです。

Well, I can say that works are unreasonable things

-----

ともあれ、システムエンジニアの一人として、

Anyway, as a systems engineer,

―― ダウンしないシステムなんて、存在しない

"Any system goes down"

ということだけは、申し上げたいのです。

I would like to say that.

2020/09,江端さんの忘備録

市役所から肝炎ウイルス検診の案内が来まして、現在、市の指定の診療所に来ています。

The city hall has sent me a guide to hepatitis virus screening, and I am currently at a clinic.

背景は良く分かっていませんが、「生涯1度だけの検診 + 無料」ということなので、受診してきました。

I don't know the background well, but I went to see it because it means "one-time examination + free of charge".

それに、セルシン(精神安定剤)の処方もして貰うことにしました。

I also decided to get a prescription for celsine (tranquilizer).

-----

私、結構長いこと、人間ドッグで「脂肪肝」を指摘されて続けていました。

I have been pointing out "fatty liver" in human dogs for quite a long time.

ダイエット(のコラム執筆)と、断酒によって、ようやく、これから逃れることができるようになりました。

By dieting (writing a column) and abstaining from alcohol, I was finally able to escape from this.

断酒の効果であるかかどうかは、はっきりと分からないのですが、「肩コリ」「腰痛」が、劇的に改善されました。

I'm not sure if it's the effect of abstinence, but "shoulder stiffness" and "backache" have improved dramatically.

「不眠」は、"アルコール"が"セルシン"に代わっただけ、という見方もできますが、大きな改善点は、『うたたね』ができるようになったことです。

It can be said that "insomnia" is just a replacement of "alcohol" with "selcin", but the major improvement is the ability to take a "nap".

これによって、仕事(特に連続10数時間のコラム執筆)中に、10分間程度の仮眠できるようになったことは、大きいです。

It is great that I was able to take a nap for about 10 minutes during work (especially writing a column for more than 10 hours in a row).

まあ、「アルコールを摂取することで睡眠時間を確保していた」という事実は、「アルコールに依存することで、無理矢理、眠りを得ていた」と言える訳で、つまるところ

Well, the fact that "I was able to secure sleep time by consuming alcohol" can be said to be "I was forced to sleep by depending on alcohol", after all, I can't deny

『アルコール依存症』

"Alcoholism"

を、否定することはできないでしょう。

-----

以前もお話しましたが、アルコール依存症であった私にとって、コンビニのお酒の棚の列は、今なお結構な「地獄ロード」です。

As I said before, for me, who was an alcoholic, the rows of liquor shelves at convenience stores are still quite a "hell road".

あれ、マジでキツイです。

That is really hard.

あのロードを止まらずに突っ切るのは、相当な精神力や胆力を必要とします。

It takes a great deal of mental strength and courage to pass through that road without stopping.

「酒が飲めないことは、人生の半分を損している」と言われますが ―― 全く同感です。

It is said that "No drink, no life". I totally agree.

お酒というのは、人類が生み出した至宝の飲料です。

Alcohol is a treasure drink produced by humankind.

それでも、私が酒を断っているのは、

Still, the reason I refuse to drink is

―― まだまだ、書きたい物(コラムとプログラム)が沢山残っているから

"There are still a lot of things I want to write (columns and programs)"

です。

-----

とは言え、始終、頭がクリアで居続けるのは、なかなか辛いものです。

However, it's hard to stay clear from beginning to end.

コラムを書き上げた時とか、プログラムが動いた時は「ご褒美に、一杯やりたい」です。

When I finish writing the column, or when the program works well, I want to give a drink as a reward.

それ故、私は、安全性が担保され、習慣性がなく、依存性もなく、一定時間後には完全に正気に戻る(合法であることは言うまでもない)という ―― そういう、薬や嗜好品の開発をやりたい。

Therefore, I I want to do development of kind of medicine or luxury item, with safe, non-addictive, non-dependent, and completely going back to sane after a period of time (not to mention legal).

------

リタイア後に、再度大学受験をして、化学科に入学するのもいいな、と考えています。

After retirement, I think it would be good to take the university entrance exam again and enroll in the Department of Chemistry.

志望動機を問われたら

If I am asked about my motive, I will answer

『安全性を完全に担保した、究極の覚醒剤の開発です』

"Development of the ultimate stimulant that completely guarantees safety"

と答える予定です。

2020/09,江端さんの忘備録,江端さんの技術メモ

https://www.prakharsrivastav.com/posts/from-http-to-https-using-go/ が原典

Goを使ってHTTPからHTTPSへ
2019-08-02 :: プラカール・スリバスタフ

序章
この記事では、Go で TLS 暗号化を設定する方法を学びます。さらに、相互にTLS暗号化を設定する方法を探っていきます。このブログ記事で紹介されているコードはこちらからご覧いただけます。この記事では、関連するスニペットを表示しています。興味のある読者は、リポジトリをクローンしてそれに従ってください。

まず、シンプルな Http サーバとクライアントを Go で書くことから始めます。次に、サーバで TLS を設定することで、両者間のトラフィックを暗号化します。この記事の最後に、両者間の相互 TLS を設定します。

シンプルなhttpサーバー
まず、Go で Http クライアント・サーバの実装を作成してみましょう。localhost:8080 に到達可能な Http エンドポイント /server を公開します。そして、http.Clientを使ってエンドポイントを呼び出し、その結果を表示します。

完全な実装はこちらを参照してください。

// Server code
mux := http.NewServeMux()
mux.HandleFunc("/server", func(w http.ResponseWriter, r *http.Request) {
  fmt.Fprint(w, "Protect Me...")
})
log.Fatal(http.ListenAndServe(":8080", mux))


// Client code
if r, err = http.NewRequest(http.MethodGet, "http://localhost:8080/server", nil); err != nil {
	log.Fatalf("request failed : %v", err)
}

c := http.Client{
	Timeout:   time.Second * 5,
	Transport: &http.Transport{IdleConnTimeout: 10 * time.Second},
}

if data, err = callServer(c, r); err != nil {
	log.Fatal(err)
}
log.Println(data) // Should print "Protect Me..."

次のセクションでは、TLS を使用してクライアントとサーバ間のトラフィックを暗号化します。その前に、公開鍵インフラストラクチャ (PKI) をセットアップする必要があります。

PKI のセットアップ
ミニ PKI インフラストラクチャをセットアップするために、minica という Go ユーティリティを使用して、ルート、サーバ、クライアントの鍵ペアと証明書を作成します。実際には、認証局 (CA) またはドメイン管理者 (組織内) が鍵ペアと署名付き証明書を提供してくれます。私たちの場合は、minicaを使ってこれをプロビジョニングしてもらうことにします。

鍵ペアと証明書の生成
注: これらを生成するのが面倒に思える場合は、Github リポジトリでコミットされた証明書を再利用することができます。

以下の手順で証明書を生成します。

minicaをインストールする: github.com/jsha/minicaを取得してください。
minica --domains server-certを実行してサーバ証明書を作成します。
初めて実行すると4つのファイルが生成されます。
minica.pem(ルート証明書
minica-key.pem (root 用の秘密鍵)
server-cert/cert.pem (ドメイン「server-cert」の証明書、ルートの公開鍵で署名されています)
server-cert/key.pem (ドメイン「server-cert」の秘密鍵)
minica --domains client-certを実行してクライアント証明書を作成します。2つの新しいファイルが生成されます。
client-cert/cert.pem (ドメイン "client-cert "の証明書)
client-cert/key.pem (ドメイン "client-cert "の秘密鍵)
また、minicaでドメインの代わりにIPを使用して鍵ペアや証明書を生成することもできます。

etc/hosts にエイリアスを設定する
上記で生成したクライアント証明書とサーバ証明書は、それぞれドメイン server-cert と client-cert で有効です。これらのドメインは存在しないので、localhost(127.0.0.1)のエイリアスを作成します。これを設定すると、localhost の代わりに server-cert を使用して Http サーバにアクセスできるようになります。

Linux以外のプラットフォームを使っている場合は、OSに合わせた設定方法をググってみてください。私はLinuxマシンを使っていますが、ドメインエイリアスの設定はとても簡単です。etc/hostsファイルを開き、以下の項目を追加します。

127.0.0.1       server-cert
127.0.0.1       client-cert

この時点で、インフラストラクチャの設定は完了です。次のセクションでは、クライアントとサーバ間のトラフィックを暗号化するために、これらの証明書を使ってサーバを設定します。

サーバーでTLSを設定する
サーバ-certドメインに生成された鍵と証明書を使って、サーバにTLSを設定してみましょう。クライアントは先ほどと同じです。唯一の違いは、3つの異なるURLでサーバを呼び出すことで、何が起こっているのかを理解することです。

完全な実装はこちら

// Server configuration
mux := http.NewServeMux()
mux.HandleFunc("/server", func(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, "i am protected")
})
log.Println("starting server")
// Here we use ListenAndServerTLS() instead of ListenAndServe()
// CertPath and KeyPath are location for certificate and key for server-cer
log.Fatal(http.ListenAndServeTLS(":8080", CertPath, KeyPath, mux))

// Server configuration
c := http.Client{
    Timeout:   5 * time.Second,
    Transport: &http.Transport{IdleConnTimeout: 10 * time.Second,},
}

if r, err = http.NewRequest(http.MethodGet, "http://localhost:8080/server", nil); err != nil { // 1
//if r, err = http.NewRequest(http.MethodGet, "https://localhost:8080/server", nil); err != nil { // 2
//if r, err = http.NewRequest(http.MethodGet, "https://server-cert:8080/server", nil); err != nil { // 3
    log.Fatalf("request failed : %v", err)
}

if data, err = callServer(c, r); err != nil {
    log.Fatal(err)
}
log.Println(data)

http.ListenAndServeTLS()を使用してサーバを起動します。これにはポート、公開証明書へのパス、秘密鍵へのパス、そしてHttp-handlerの4つの引数が必要です。サーバからのレスポンスを見てみましょう。私たちは失敗しますが、私たちはどのようにHttp暗号化が動作するかについてのより多くの洞察を与える3つの異なる要求を送信します。

Attepmt 1 http://localhost:8080/server に送信すると、応答があります。

Client Error. Get http://localhost:8080/server: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x15\x03x01x00x02\x02"

サーバエラー: http: 127.0.0.1:35694 からの TLS ハンドシェイクエラー: tls: 最初のレコードが TLS ハンドシェイクのように見えません。

これは、サーバーが暗号化されたデータを送信していることを意味する良いニュースです。Http経由では誰も意味をなさないでしょう。

Attempt 2 to https://localhost:8080/server、レスポンスは以下の通りです。

クライアントエラーです。Get https://localhost:8080/server: x509: certificate is valid for server-cert, not localhost

サーバエラー: http: 127.0.0.1:35698 からの TLS ハンドシェイクエラー: リモートエラー: tls: 不正な証明書

これはまたしても朗報です。これは、ドメインサーバ証明書に発行された証明書を他のドメイン(ローカルホスト)で使用することができないことを意味します。

Attempt 3 to https://server-cert:8080/server、応答があります。

クライアントエラーです。Get https://server-cert:8080/server: x509: certificate signed by unknown authority

サーバエラー: http: 127.0.0.1:35700 からの TLS ハンドシェイクエラー: リモートエラー: tls: 不正な証明書

このエラーは、クライアントがその証明書に署名したことを信頼していないことを示しています。クライアントは証明書に署名した CA を認識していなければなりません。

このセクションの全体的な考えは、TLS が保証する 3 つの保証を実証することでした。

メッセージは常に暗号化されている。
サーバが実際に言っている通りのものであること。
クライアントはサーバの証明書を盲目的に信じてはいけない。クライアントは、CA を通じてサーバの身元を確認できるようにしなければなりません。

クライアントでCA証明書を設定する
クライアント側のCA証明書を設定して、ルートCAの証明書とサーバの身元を照合できるようにします。サーバ証明書はルートCAの公開鍵を使って署名されているので、TLSハンドシェイクが有効になり、通信が暗号化されます。

完全な実装はこちらにあります。

// create a Certificate pool to hold one or more CA certificates
rootCAPool := x509.NewCertPool()

// read minica certificate (which is CA in our case) and add to the Certificate Pool
rootCA, err := ioutil.ReadFile(RootCertificatePath)
if err != nil {
    log.Fatalf("reading cert failed : %v", err)
}
rootCAPool.AppendCertsFromPEM(rootCA)
log.Println("RootCA loaded")

// in the http client configuration, add TLS configuration and add the RootCAs
c := http.Client{
    Timeout: 5 * time.Second,
    Transport: &http.Transport{
        IdleConnTimeout: 10 * time.Second,
        TLSClientConfig: &tls.Config{RootCAs: rootCAPool},
    },
}

if r, err = http.NewRequest(http.MethodGet, "https://server-cert:8080/server", nil); err != nil {
    log.Fatalf("request failed : %v", err)
}

if data, err = callServer(c, r); err != nil {
    log.Fatal(err)
}
log.Println(data)

// server response
prakhar@tardis (master)? % go run client.go  
RootCA loaded
i am protected # response from server

これにより、先ほど説明した3つの保証がすべて保証されます。

相互TLSの設定
サーバーにクライアントの信頼を確立しています。しかし、多くのユースケースでは、サーバーがクライアントを信頼する必要があります。例えば、金融、医療、公共サービス業界などです。これらのシナリオのために、クライアントとサーバーの間で相互にTLSを設定して、双方がお互いを信頼できるようにします。

TLSプロトコルは、最初からこれをサポートしています。相互TLS認証を設定するために必要な手順は以下の通りです。

1.サーバはCA(CA-1)から証明書を取得します。クライアントは、サーバの証明書に署名したCA-1の公開証明書を持っている必要があります。
2.クライアントは CA (CA-2) から証明書を取得します。サーバは、クライアントの証明書に署名したCA-2の公開証明書を持っていなければなりません。簡単にするために、クライアント証明書とサーバ証明書の両方に署名するために同じ CA (CA-1 == CA-2) を使用します。
3.サーバは、すべてのクライアントを検証するためにCA証明書プールを作成します。この時点で、サーバはCA-2の公開証明書を含む。
4.同様に、クライアントは独自のCA証明書プールを作成し、CA-1の公開証明書を含む。
5.両者は、CA 証明書プールに対して受信要求を検証します。どちらか一方に検証エラーがあった場合、接続は中断されます。
実際に動作を見てみましょう。この機能の完全な実装はこちらを参照してください。

サーバーの設定

mux := http.NewServeMux()
mux.HandleFunc("/server", func(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, "i am protected")
})

clientCA, err := ioutil.ReadFile(RootCertificatePath)
if err != nil {
    log.Fatalf("reading cert failed : %v", err)
}
clientCAPool := x509.NewCertPool()
clientCAPool.AppendCertsFromPEM(clientCA)
log.Println("ClientCA loaded")

s := &http.Server{
    Handler: mux,
    Addr:    ":8080",
    TLSConfig: &tls.Config{
        ClientCAs:  clientCAPool,
        ClientAuth: tls.RequireAndVerifyClientCert,
        GetCertificate: func(info *tls.ClientHelloInfo) (certificate *tls.Certificate, e error) {
            c, err := tls.LoadX509KeyPair(CertPath, KeyPath)
            if err != nil {
                fmt.Printf("Error loading key pair: %v\n", err)
                return nil, err
            }
            return &c, nil
        },
    },
}
log.Fatal(s.ListenAndServeTLS("", ""))

この設定で注意すべき点がいくつかあります。

  1. http.ListenAndServeTLS() の代わりに server.ListenAndServerTLS() を使用します。
  2. サーバ証明書と鍵を tls.Config.GetCertificate 関数の中にロードします。
  3. サーバが信頼すべきクライアント CA 証明書のプールを作成します。
  4. tls.Config.ClientAuth = tls.RequireAndVerifyClientCertを設定し、接続しようとするすべてのクライアントの証明書を常に検証します。検証されたクライアントのみが会話を続けることができます。

クライアント設定
http.Clientの設定は、クライアントの設定も少し変わります。

rootCA, err := ioutil.ReadFile(RootCertificatePath)
if err != nil {
    log.Fatalf("reading cert failed : %v", err)
}
rootCAPool := x509.NewCertPool()
rootCAPool.AppendCertsFromPEM(rootCA)
log.Println("RootCA loaded")

c := http.Client{
    Timeout: 5 * time.Second,
    Transport: &http.Transport{
        IdleConnTimeout: 10 * time.Second,
        TLSClientConfig: &tls.Config{
            RootCAs: rootCAPool,
            GetClientCertificate: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) {
                c, err := tls.LoadX509KeyPair(ClientCertPath, ClientKeyPath)
                if err != nil {
                    fmt.Printf("Error loading key pair: %v\n", err)
                    return nil, err
                }
                return &c, nil
            },
        },
    },
}

サーバと比較した場合の設定の違いに注目してください。

  1. tls.Configでは、サーバー上のClientCAの設定に対して証明書プールをロードするためにRootCAを使用しています。
  2. tls.Config.GetClientCertificate を使用して、サーバー上の tls.Config.GetCertificate に対してクライアント証明書をロードしています。
  3. GitHub の実際のコードにはいくつかのコールバックがあり、これを使って証明書の情報を見ることもできます。

クライアントとサーバの相互TLS認証の実行

# Server logs
2019/08/01 20:00:50 starting server
2019/08/01 20:00:50 ClientCA loaded
2019/08/01 20:01:01 client requested certificate
Verified certificate chain from peer:
  Cert 0:
    Subject [client-cert] # Server shows the client certificate details
    Usage [1 2]
    Issued by minica root ca 5b4bc5 
    Issued by 
  Cert 1:
    Self-signed certificate minica root ca 5b4bc5

# Client logs
2019/08/01 20:01:01 RootCA loaded
Verified certificate chain from peer:
  Cert 0:
    Subject [server-cert] # Client knows the server certificate details
    Usage [1 2]
    Issued by minica root ca 5b4bc5
    Issued by 
  Cert 1:
    Self-signed certificate minica root ca 5b4bc5
2019/08/01 20:01:01 request from server
2019/08/01 20:01:01 i am protected

結論
TLS の設定は、実装の問題というよりも証明書の管理の問題が常にあります。TLS 設定における典型的な混乱は、実装というよりも正しい証明書の使用に関連していることが多いです。TLS プロトコルとハンドシェイクを正しく理解していれば、Go は箱から出してすぐに必要なものをすべて提供してくれます。

また、理論的な観点からTLSの暗号化とセキュリティを探求した以前の記事もチェックしてみてください。

参考文献
この記事は、Gophercon-2018でのLiz Riceの素晴らしいトークに大きく影響されていますので、ぜひチェックしてみてください。その他の参考文献は以下の通りです。

secure-connections: gophercon のためのレポ
minica 認証局
Eric Chiangによるこの驚くべき記事。必読です。
step-by-step-guide-to-mtls-in-go.
mediumのこの記事。

2020/09,江端さんの忘備録

本日は、コラムがリリースされた日なので、日記はお休みです。

Today, new my column is released, so I take a day off.

踊るバズワード ~Behind the Buzzword(6)量子コンピュータ(6):

ひねくれボッチのエンジニアも感動で震えた「量子コンピュータ至高の技術」

Dancing Buzzword-Behind the Buzzword (6) Quantum Computer (6)

Even a cynical lonely engineer was moved to tears by the "supreme technology of the quantum computer"

-----

今回、量子コンピュータの最終回です。

This is the final installment of the "Quantum Computer" series.

最終回なので、監修をして頂いた、ご自称「量子コンピュータオタクのTさん」に、コメントの寄稿をお願いしたのですが、

As this is the last episode, I asked the self-proclaimed "quantum computer geek, Mr. T", who supervised the article, to contribute a comment.

『少し考えてみましたが、いい文章が浮かばなかった』

"I gave it some thought, but I couldn't come up with a good sentence"

との理由でご辞退されました。

He declined to do so because of the reason.

まあ、突然寄稿を依頼されて、ホイホイ応じる人間は、私の知る限り、私だけです。

Well, as far as I know, I'm the only person who is suddenly asked to contribute and responds immediately.

-----

長い間、「無礼な後輩シリーズ」として、レビューをして貰っている後輩にも、コメントの寄稿について訊ねてみたのですが、

For a long time, I asked the juniors who have been reviewing it as a "rude junior series" about contributing comments. However he said to me.

「メリットがない」

"No merit"

と一蹴されました。

I was kicked off by him.

後輩:「江端さん、もう何年もコラム書き続けているのに、全然メジャーになっていないじゃないですか」

"Ebata-san, you've been writing a column for years now, but you haven't become a major player at all.

後輩:「江端さんにフリーライド(ただ乗り)しても、私にメリットがないですよ」

"There's no benefit to me in free-riding with Ebata-san"

-----

確かに ―― その通り。

Certainly -- that's right.

コラム執筆に、こんなに膨大な時間と労力を注いでいるのに、「日の当たるところにいる」という感覚が ―― "ゼロ"

I've put such an enormous amount of time and effort into writing the column, however, the sense of "being in the sun" is "zero"

何故だろう。おかしい。なぜ、私の努力はこんなにも空回りしてしまうのだろう。

I don't know why. It's funny. Why are my efforts so spinning out of control?

―― というような話を、嫁さんにしたところ、

I told my wife about the story, and she said

嫁さん:「そもそも『メジャーになりたい』と思っているの?」

Wife: "Do you want to 'be a major player' in the first place?

と、言われました。

-----

あ、どんどん、嫌なことを思い出してきた。

Oh, I'm starting to remember more and more of the bad stuff.

そういえば、大学院の入試勉強の際にも、

Come to think of it, when I was studying for my graduate school entrance exam.

―― エバちゃんってさぁ、「入試の目的(合格)」を忘れて、「勉強の為に勉強する」ようになるから、心配だよ

I'm worried about you, Eba-chan, because you're going to forget the purpose of the entrance exam (passing) and start "studying for the sake of studying".

と、下宿に閉じ籠って勉強している私に、手紙を送ってくれたゼミの友人(女性)のメッセージを思い出してしまいました。

It reminded me of a message from a seminar friend (a woman) who sent me a letter, when I was studying in the boarding house.

# 電子メールを使うだけで、オタク呼ばわりされた時代でした(BBS(nifty)経由のみ)

# It was an era when people were called nerds just by using e-mail (only via BBS (nifty))

-----

そういえば、私、"メジャー"というものも、よく分からないんですよ。

By the way, I don't really understand what the "major" is.

どのくらい分からないかと言えば、「東京に出てきて、一旗上げる」という、その「旗」の内容が分からない程度に、分からないです。

I don't know it like the contents of a "flag" of "raising in Tokyo".

2020/09,江端さんの忘備録

今日は、母の施術の立ち会いの為に、会社を休んで、病院に行ってきました。

Today, I took a day off from work to go to the hospital to witness my mother's treatment.

フェイスシールドを準備しての万端の体制だったのですが、病院では、看護師さんもフェースシールドをしていませんでした。

I was all set up with a face shield at the ready, but at the hospital, the nurses didn't have a face shield either.

悪目立ちするのも何なので、今回は、フェースシールドを使うのはやめました。

I didn't want to stand out, so I decided not to use the face shield this time.

それはさておき。

Aside from that.

-----

昨日お話しましたが、体中の筋肉痛がハンパなく酷いので、実家の方のスーパー銭湯にいって、サウナ3セットをやってきました。

As I told you yesterday, I went to the super public bath at my parents' house and did three sets of sauna sessions because the muscle pain in my body was so bad.

サウナの中で流れているテレビ番組を ―― 苦痛を感じながら聞いていました。

I listened to the TV show playing in the sauna -- painfully.

著名な女優さんが自殺するのは痛ましいし、元アイドルグループのメンバが、飲酒運転の上に事故を起こすのは非難されてしかるべきです。

It's tragic to see a famous actress kill herself and a former member of an idol group should be blamed for causing an accident on top of a drunk driver.

―― しかし、大人が数人も集って、何十分も語るようなネタか?

"However, is this the kind of story that a few adults can get together and talk about for 20 minutes?"

うん、そういうネタなんだろう。

I thought "Yes, it is".

そういうネタだから、真っ昼間から放送されている訳です。

That's why it's being broadcast from daytime.

それだけのリソースを投入するなら、ソリューション(解決法)の議論でもすればいいのに ―― と思ってしまうのは、私がエンジニアだからかもしれません。

I thought "If they want to invest that much resources, they can discuss the solution", however, it may be because I am an engineer.

-----

個人的意見としては、

In my personal opinion,

―― サウナ室は無声、無音でいい

"Sauna rooms can be silent"

と思うのですが、サウナ利用者としては、ボーッとするよりは、テレビが流れていた方が気が紛れるということもあるのかもしれません。

However, as a sauna user, it may be more distracting to have the TV on than to be dumb.

うん、無声、無音では、サウナ室が、座禅の修行所のような感じになってしまうだろう(私は、それでもいいと思うのですが)。

Yeah, the sauna room will look like a zazen training center(I think that's fine).

私としては、早いところ、

I do expect that

■サウナ対応(完全防水、上限温度120度)のタブレットの開発

- Development of tablet compatible with sauna (fully waterproof, maximum temperature 120 degrees)

と、

and

■そのタブレットとイヤホンの銭湯への持ち込み

- Bringing the tablet and earphones to the public bath

を期待したいところです。

"VRゴーグル"でも可です。

"VR goggles" are also acceptable.

2020/09,江端さんの忘備録

無人の実家 ―― 江端のセキュリティシステムがガッチリ守っていますが ―― に帰省して、実に半年ぶりの庭手入れをしました。

I went to uninhabited my parents house, and tended the garden for the first time in six months, though Ebata's security system is protecting my garden.

庭が、雑草でエラいことになっていました。

The garden was getting out of control because of the weeds.

草や木を、電動チェーンソーで裁断しまくり、その後に、50m平方メートル相当の防草シートを敷設しました。

We cut all the grass and trees with an electric chainsaw and then laid down 50m square meters of weed control sheeting.

裁断した草木は、回収用ゴミ袋を14袋を使いました。

For the plants and trees cut, I used 14 bags of garbage for collection.

今回、役に立ったのは、携帯用の蚊取り線香です。

What helped me this time was a portable mosquito coil.

これを2つ購入して、ズボンの前後に装着していました。

I bought two of these and wore them on the front and back of my pants.

原始的なモノほど効果がある、というのを実感しました。

I have found that the more primitive the object, the more effective it is.

前日の作業では、何箇所か薮蚊に刺されていましたが、本日は被害はゼロでした。

During the previous day's work, there were several bush mosquito bites, but today there was no damage.

で、それはさておき。

And that's beside the point.

-----

昨夜は、腕が震えて箸が使えませんでした。

Last night my arms were shaking and I couldn't use chopsticks.

本気で「アル中」になったのかと思いましたよ ―― 禁酒してかなり経つというのに。

I seriously thought I have been an "alcoholic" -- however, I've been sober for quite a while now.

どうやら電動チェーンソーの使いすぎが原因らしいです。今朝は直っていましたので。

Apparently it's due to overuse of the electric chainsaw. I was able to get it fixed this morning.

しかし、腰から背中への痛み(筋肉痛)が半端ではなく、午前中はなんども眩暈(めまい)を起こして、作業を中断しながらの作業でした ―― ちなみに、飲料水はリットルレベルで補給していましたが。

But the pain (muscle pain) of my back was so bad. In the morning, I got dizzy many times and had to stop working for a while. Even I was replenishing my drinking water at the liter level.

これまでに体験したことのない現象で、ちょっと衝撃受けています。

It's a phenomenon I've never experienced before and I'm a bit shocked.

コロナ自粛による運動不足か ―― もう本格的に「老化」かもしれません。

Lack of exercise due to Corona self-restraint -- it may be full-blown "aging" already.