curl実行時に
curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small
というエラーが発生した時の、一時的に手っ取り早く解決する方法を紹介します
$ curl https://www.jisha.or.jp/slogan/result/slogan04.html
curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small
curl オプション --cipher 'DEFAULT:!DH' を使います
$ curl --cipher 'DEFAULT:!DH' https://www.jisha.or.jp/slogan/result/slogan04.html | head
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 20366 100 20366 0 0 292k 0 --:--:-- --:--:-- --:--:-- 292k<!DOCTYPE HTML>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=1160" id="viewport">
<!-- ▼ title ▼ -->
<title>中災防:過去の年間標語</title>
<!-- ▼ meta ▼ -->
<meta name="keywords" content="" />
curl https://www.stat.go.jp/data/mesh/m_itiran.html
curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small
# --cipher 'DEFAULT:!DH' するも・・・
curl --cipher 'DEFAULT:!DH' https://www.stat.go.jp/data/mesh/m_itiran.html
curl: (35) error:1414D172:SSL routines:tls12_check_peer_sigalg:wrong signature type
OpenSSL SECLEVELによるwrong signature typeエラーの概要 - designetwork
によると、セキュリティレベルを一時的に下げればどうにかなるらしいので --cipher 'DEFAULT:@SECLEVEL=1' を使います
curl --cipher 'DEFAULT:@SECLEVEL=1' https://www.stat.go.jp/data/mesh/m_itiran.html
<html><head><title>Request Rejected</title></head><body>The requested URL was rejected. Please consult with your administrator.<br><br>Your support ID is: 6133672768412417981</body></html>
これでアクセスできます。
ちなみに「The requested URL was rejected. 」云々は暗号化とは別の話で、 User-Agent を指定すれば回避できます
curl --cipher 'DEFAULT:@SECLEVEL=1' -A hoge https://www.stat.go.jp/data/mesh/m_itiran.html | head
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="Shift_JIS">
<meta http-equiv="x-ua-compatible" content="IE=Edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no">
(略)