foo.localhostを使用して自己署名証明書を作成しました。紹介を暗号化しましょうこのMakefileを使用してください:
include ../.env
configuration = csr.cnf
certificate = self-signed.crt
key = self-signed.key
.PHONY: all
all: $(certificate)
$(certificate): $(configuration)
openssl req -x509 -out $@ -keyout $(key) -newkey rsa:2048 -nodes -sha256 -subj '/CN=$(HOSTNAME)' -extensions EXT -config $(configuration)
$(configuration):
printf "[dn]\nCN=$(HOSTNAME)\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:$(HOSTNAME)\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth" > $@
.PHONY: clean
clean:
$(RM) $(configuration)
次にWebサーバーに割り当てます。サーバーが関連証明書を返したことを確認しました。
$ openssl s_client -showcerts -connect foo.localhost:8443 < /dev/null
CONNECTED(00000003)
depth=0 CN = foo.localhost
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 CN = foo.localhost
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
0 s:/CN=foo.localhost
i:/CN=foo.localhost
-----BEGIN CERTIFICATE-----
[…]
-----END CERTIFICATE-----
---
Server certificate
subject=/CN=foo.localhost
issuer=/CN=foo.localhost
---
No client certificate CA names sent
Peer signing digest: SHA512
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 1330 bytes and written 269 bytes
Verification error: unable to verify the first certificate
---
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : ECDHE-RSA-AES128-GCM-SHA256
Session-ID: […]
Session-ID-ctx:
Master-Key: […]
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket:
[…]
Start Time: 1529622990
Timeout : 7200 (sec)
Verify return code: 21 (unable to verify the first certificate)
Extended master secret: no
---
DONE
cURLを信頼する方法/ etcで何も修正しませんか? --cacert
するいいえおそらくCAがないので動作します。
$ curl --cacert tls/foo.localhost.crt 'https://foo.localhost:8443/'
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
目標は、開発中にHTTPSを有効にすることです。
- すべての開発環境でDNS検証を有効にするための多くの作業がなければ、完全に本番環境に似た証明書を取得することはできません。したがって、自己署名証明書を使用する必要があります。
- もちろん、私はまだ開発環境を本番環境にできるだけ似たくしたいので、すべての証明書の問題を単に無視することはできません。この場合
curl -k
と同様に、catch (Exception e) {}
ブラウザがWebサーバーと通信するのとは異なります。
言い換えれば、私が走るとき、curl [something] https://project.local/api/foo
私は確信したいと思います。
- TLSが正しく設定されている場合自己署名証明書の保持に加えてコマンドが成功しました
- 私のTLS設定に問題がある場合自己署名証明書の保持に加えてコマンドが失敗します。
HTTPを使用するか、--insecure
2番目の基準を満たしていません。
ベストアンサー1
努力する-k
:
curl -k https://yourhost/
自己署名証明書を「承認」する必要があります。