#author("2021-04-27T10:17:12+09:00","default:nobuoki","nobuoki") #author("2021-04-27T10:17:48+09:00","default:nobuoki","nobuoki") * はじめに [#u7485d4c] curl実行時に curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small というエラーが発生した時の、一時的に手っ取り早く解決する方法を紹介します - 2021/04/27 手強い例 を追記 - 2021/04/27 手強い例(DEFAULT:@SECLEVEL=1) を追記 * エラーが出る例 [#necdbb2f] [[中災防:過去の年間標語>https://www.jisha.or.jp/slogan/result/slogan04.html]] #prism(bash){{{ $ curl https://www.jisha.or.jp/slogan/result/slogan04.html curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small }}} * 解決方法 [#tb5c58b2] curl オプション ''--cipher 'DEFAULT:!DH''' を使います #prism(bash){{{ $ 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="" /> }}} * 参考 [#m54dfa4e] - [[Debian系のLinuxでcurl実行時に「curl: (35) error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small」というエラーが発生した時の対処方法 - Qiita>https://qiita.com/notakaos/items/bb2f801ca001d950e8a3]] -- opensslのクライアント側のセキュリティレベルを下げる(/etc/ssl/openssl.cnf を編集する)方法が紹介されています - [[How to resolve the issue "DH key too small" - IMLC.ME>https://imlc.me/dh-key-too-small]] -- 上記に加え、本記事に記載した cipher オプションを使う work around が紹介されています * 手強い例 [#v4febfbe] [[統計局ホームページ/市区町村別メッシュ・コード一覧>https://www.stat.go.jp/data/mesh/m_itiran.html]] #prism(bash){{{ 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 }}} * 解決方法その2 [#fc0d3d3f] [[OpenSSL SECLEVELによるwrong signature typeエラーの概要 - designetwork>https://designetwork.daichi703n.com/entry/2020/10/03/openssl-seclevel-ubuntu-focal]] によると、セキュリティレベルを一時的に下げればどうにかなるらしいので ''--cipher 'DEFAULT:@SECLEVEL=1''' を使います #prism(bash){{{ 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 を指定すれば回避できます #prism(bash){{{ 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"> (略) }}}