DEV Community

KOGA Mitsuhiro
KOGA Mitsuhiro

Posted on • Originally published at qiita.com

certificate verify failedなsvn+httpsサーバからmercurial+hgsubversionでcloneする

certificate verify failedなsvn+httpsサーバとmercurialの連携が一筋縄ではいかなかったので手順をまとめました。
環境によっては途中の手順を飛ばせるかもしれませんし、逆に最後まで進めても解決しないかもしれません。

まずは普通にcloneしてみます。

$ hg clone https://example.org/svn/
abort: error: _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

clone元のSSL証明書がオレオレ証明書だったり有効期限が切れているとエラーになってしまいます。
そこで検証を省略するために--insecureオプションを使います。

$ hg clone --insecure https://example.org/svn/
warning: example.org certificate with fingerprint xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx not verified (check hostfingerprints or web.cacerts config setting)
abort: Failed to open Subversion repository; please try running 'svn ls https://example.org/svn/' for details.

今度はsvnライブラリでエラーになってしまうのでエラーメッセージの通りにコマンドを実行します。

$ svn ls https://example.org/svn/
Error validating server certificate for 'https://example.org:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
Certificate information:
 - Hostname: example.org
 - Valid: from Fri, 16 Sep 2011 22:55:11 GMT until Mon, 17 Sep 2012 16:58:51 GMT
 - Issuer: Foo
 - Fingerprint: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
(R)eject, accept (t)emporarily or accept (p)ermanently? 

ここではSSL証明書を常に承認するためにpを入力します。
それと--insecureオプションでは大量のwarningが出るので上記のFingerprinthostfingerprintsに追加します。
実際のFingerprintは:で区切られた16進数です。

  • Windowsの場合 %USERPROFILE%\Mercurial.ini
  • Mac, UNIX系の場合 $HOME/.hgrc
[hostfingerprints]
example.org = xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx

これでSSL証明書のエラー回避ができたので再びcloneしてみます。

$ hg clone https://example.org/svn/
destination directory: svn
abort: Failed to open Subversion repository; please try running 'svn ls https://example.org/svn/' for details.

ここでエラーメッセージが変わらない場合はsvnライブラリが使うhttpライブラリに問題があるので
serversファイルのglobalセクションのhttp-libraryserfもしくはneonを指定します。

  • Windowsの場合 %APPDATA%\Subversion\servers
  • Mac, UNIX系の場合 $HOME/.subversion/servers
[global]
http-library = serf

もしくは

[global]
http-library = neon

httpライブラリを変えたので、もう一度SSL証明書の受け入れを承認します。

$ svn ls https://example.org/svn/
Error validating server certificate for 'https://example.org:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
Certificate information:
 - Hostname: example.org
 - Valid: from Fri, 16 Sep 2011 22:55:11 GMT until Mon, 17 Sep 2012 16:58:51 GMT
 - Issuer: Foo
 - Fingerprint: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
(R)eject, accept (t)emporarily or accept (p)ermanently? 

今度こそSSL証明書のエラーを回避できたのでcloneしてみます。

$ hg clone https://example.org/svn/
destination directory: svn
abort: The OPTIONS response did not include the requested version-name value (subversion error: 1703)

今度はHTTPのOPTIONSメソッドで出てしまいました。
この場合はsvnのbranchとtagが反映されなくなりますが、singleレイアウトにするとcloneできました。

$ hg clone --layout single https://example.org/svn/
destination directory: svn

これで無事にsvn+httpsサーバからcloneできました。

Top comments (0)