絖綛 N@i.jp  昨日:00000000
 今日:00001198
 総計:00001198
keywords
管理者専用
  Post   Add link   Control Panel 































新しいトピック
最新:03/21 19:08


新しいコメント
最新:07/28 16:47






管理人へMAIL

プライバシーポリシー

ClamAV 0.102.0 が MacOS X(Tiger-PPC)でビルドできなくなっていたので強行突破してみた(2)

参照:cURL


原因は自分でビルドした curl でした


 ClamAV Ver.0.102.0 のリリースノートによると、freshclam の HTTPS通信は Libcurlに依存しているとのことです。

  • Libcurl has become a hard-dependency. Libcurl enables HTTPS support for freshclam and clamsubmit as well as communication between clamonacc and clamd.

 実際 curlで"https://database.clamav.net"にアクセスしてみると、同じエラーが起きていました。

$ curl https://database.clamav.net
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.

この"unable to get local issuer certificate"というエラーの意味は、ルート証明書が自端末(PC)内に無いと言うエラーだそうで、検索すると同じ事例が山ほど見つかりました。また「ルート証明書」についても詳しい説明がいくらでも見つかりますので、そちらを参照してください。
 Webブラウザは、いくつかの信頼できる認証局(CA)による「ルート証明書」を持っていて、暗号(公開)鍵に付いている認証局の署名の階層を上に辿り、「ルート証明書」にある認証局に辿り着けたら、その鍵は信頼できるものと判断します。

 しかし自分がビルドした curlではルート証明書のファイルをどこに配置するか(どのルート証明書ファイルを使用するか)指定していなかったし、実行時にも(オプションまたは環境変数で)指定していなかったので、"unable to get local issuer certificate"エラーになってしまったのでした。当然、Libcurl を使用している freshclam でも同じエラーになるわけですね。

 エラーの詳細についてはhttps://curl.haxx.se/docs/sslcerts.htmlを見ろとのことです。そこの「Certificate Verification」に、いくつか対処方法が書かれていました。今回は、

  1. Add the CA cert for your server to the existing default CA certificate store. The default CA certificate store can changed at compile time with the following configure options:

    --with-ca-bundle=FILE: use the specified file as CA certificate store. CA certificates need to be concatenated in PEM format into this file.

をやってみます。という事で、先ずは curl から作り直す必要があります。curl の Version は現時点での最新版 7.66.0 です。具体的には curl をビルドする際の configure に

./configure \
    〜略〜
    --with-ca-bundle="/usr/local/share/curl/cacert.pem" \ ←これ
    --with-nghttp2="/usr/local"  ←おまけで http/2 もサポートしておこう

を指定してビルドします(*1)。次に、https://curl.haxx.se/ca/cacert.pemをダウンロードして、configure に指定した "/usr/local/share/curl/cacert.pem" に配置します。以下では https://curl.haxx.se/ca/cacert.pem のダウンロードに wgetを使っていますが、Webブラウザを使用してダウンロードしても構いません。

$ sudo mkdir /usr/local/share/curl
$ wget https://curl.haxx.se/ca/cacert.pem
$ sudo cp cacert.pem /usr/local/share/curl/cacert.pem
$ sudo chmod 444 /usr/local/share/curl/cacert.pem

 これで先にエラーになった "https://database.clamav.net" に curlでアクセスしてみると、

$ curl https://database.clamav.net
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <meta content="15;url=http://www.clamav.net" http-equiv="Refresh">
  <title>ClamAV database mirror</title>
</head>
<body>
<div style="text-align: center;">
<big>
<img style="width: 125px; height: 102px;" alt="ClamAV logo"
 src="//www.clamav.net/assets/clamav-trademark.png">
</big>
<br>
</div>
<br>
<br>
You reached one of ClamAV virus database mirrors: <a
 style="font-style: italic;" href="http://database.clamav.net">database.clamav.net</a>
is a round robin record that tries to equally balance the traffic
between all the database mirrors.<br>
For a complete list of our mirrors visit <a
 href="http://www.clamav.net/mirrors.html">http://www.clamav.net/mirrors.html</a><br>
<br>
<br>
You'll be redirected to ClamAV home page (<a
 href="http://www.clamav.net">http://www.clamav.net</a>) in 15
seconds...<br>
<br>
<br>
<hr style="width: 100%; height: 2px;"><small style="font-weight: bold;">This
mirror is sponsored by </small><br>
<br>
<img alt="Sponsor Logo" src="local_logo.png"><br>
<br>
</body>
</html>
$ 

やったね!エラーが起きなくなりましたよ。

 ClamAV の freshclam は Libcurl をダイナミックリンクしているので再ビルドの必要はなく、再実行するだけで以下のとおり無事にエラーなく実行できるようになりました。

$ sudo /usr/local/clamXav/bin/freshclam --verbose
ClamAV update process started at Mon Oct 28 18:25:29 2019
Current working dir is /usr/local/clamXav/share/clamav/
Current working dir restored to /Users/nai
Querying current.cvd.clamav.net
TTL: 1741
fc_dns_query_update_info: Software version from DNS: 0.102.0
Current working dir is /usr/local/clamXav/share/clamav/
check_for_new_database_version: Local copy of daily found: daily.cld.
query_remote_database_version: daily.cvd version from DNS: 25616
daily database available for update (local version: 25615, remote version: 25616)
Current database is 1 version behind.
Downloading database patch # 25616...
Retrieving https://database.clamav.net/daily-25616.cdiff
downloadFile: Download source:      https://database.clamav.net/daily-25616.cdiff
downloadFile: Download destination: ./clamav-fcb802544be8a4fbeccc1642d1c83553.tmp
*   Trying 104.16.219.84:443...
* TCP_NODELAY set
* Connected to database.clamav.net (104.16.219.84) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /usr/local/share/curl/cacert.pem
  CApath: none
* SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
*  subject: OU=Domain Control Validated; OU=PositiveSSL Multi-Domain; CN=ssl392509.cloudflaressl.com
*  start date: Aug 24 00:00:00 2019 GMT
*  expire date: Mar  1 23:59:59 2020 GMT
*  subjectAltName: host "database.clamav.net" matched cert's "*.clamav.net"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO ECC Domain Validation Secure Server CA 2
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x2805000)
> GET /daily-25616.cdiff HTTP/2
Host: database.clamav.net
User-Agent: ClamAV/0.102.0 (OS: darwin8.11.0, ARCH: ppc, CPU: powerpc)
Accept: */*
Connection: close

* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200
< date: Mon, 28 Oct 2019 09:25:44 GMT
< content-type: application/octet-stream
< content-length: 32305
< set-cookie: __cfduid=d88ba73378ee88a171de8fc1662f9ef771572254744; expires=Tue, 27-Oct-20 09:25:44 GMT; path=/; domain=.clamav.net; HttpOnly
< last-modified: Mon, 28 Oct 2019 08:57:00 GMT
< etag: "5db6ad5c-7e31"
< expires: Tue, 27 Oct 2020 09:13:33 GMT
< cache-control: public, max-age=31535269
< cf-cache-status: HIT
< age: 934
< accept-ranges: bytes
< strict-transport-security: max-age=15552000
< x-content-type-options: nosniff
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< server: cloudflare
< cf-ray: 52cbdd3b28a0ae9d-KIX
<
Time: 0.4s, ETA; 0.0s [=======================================>] 0.03KiB/0.03KiB
* Connection #0 to host database.clamav.net left intact
cdiff_apply: Parsed 1217 lines and executed 1217 commands
updatedb: Running g_cb_download_complete callback...
download_complete_callback: Download complete for database : /usr/local/clamXav/share/clamav/tmp/clamav-cedb7bdb7f410f3cf7a5a74e78838a1f.tmp-daily.cld
download_complete_callback:   fc_context->bTestDatabases   : 1
download_complete_callback:   fc_context->bBytecodeEnabled : 1
Testing database: '/usr/local/clamXav/share/clamav/tmp/clamav-cedb7bdb7f410f3cf7a5a74e78838a1f.tmp-daily.cld' ...
Loading signatures from /usr/local/clamXav/share/clamav/tmp/clamav-cedb7bdb7f410f3cf7a5a74e78838a1f.tmp-daily.cld
Properly loaded 1960147 signatures from /usr/local/clamXav/share/clamav/tmp/clamav-cedb7bdb7f410f3cf7a5a74e78838a1f.tmp-daily.cld
Database test passed.
daily.cld updated (version: 25616, sigs: 1960147, f-level: 63, builder: raynman)
fc_update_database: daily.cld updated.
Current working dir restored to /Users/nai
Current working dir is /usr/local/clamXav/share/clamav/
check_for_new_database_version: Local copy of main found: main.cvd.
query_remote_database_version: main.cvd version from DNS: 58
main.cvd database is up to date (version: 58, sigs: 4566249, f-level: 60, builder: sigmgr)
fc_update_database: main.cvd already up-to-date.
Current working dir restored to /Users/nai
Current working dir is /usr/local/clamXav/share/clamav/
check_for_new_database_version: Local copy of bytecode found: bytecode.cld.
query_remote_database_version: bytecode.cvd version from DNS: 331
bytecode.cld database is up to date (version: 331, sigs: 94, f-level: 63, builder: anvilleg)
fc_update_database: bytecode.cld already up-to-date.
Current working dir restored to /Users/hogehoge
$ 

 これで ClamAV-0.102.0 が Mac OS X (Tiger-PPC)でも動作するようになり、強行突破完了です。しかし ClamAV のメモリ消費量は相変らずで、メモリ1GBのマシンではスキャンさせると耐えられないほど動作が重くなります。何とかならんもんですかねぇ・・・


備考(*1):現在の curlビルド用スクリプトはこんな感じ。

#!/usr/local/bin/bash -x

export MACOSX_DEPLOYMENT_TARGET=10.4
export GCC="/usr/local"
export SSL="/usr/local/libressl"
export PKG_CONFIG_PATH="${SSL}/lib/pkgconfig:${PKG_CONFIG_PATH}"
export PATH="${GCC}/bin:${PATH}"
export DYLD_LIBRARY_PATH="${GCC}/lib:${DYLD_LIBRARY_PATH}"

./configure \
    --enable-http \
    --enable-file \
    --enable-ldap \
    --disable-ldaps \
    --enable-proxy \
    --enable-telnet \
    --enable-smb \
    --enable-libcurl-option \
    --enable-ipv6 \
    --enable-verbose \
    --enable-crypto-auth \
    --enable-hidden-symbols \
    --enable-threaded-resolver \
    --with-gssapi=/usr \
    --with-zlib=/usr \
    --with-ssl=${SSL} \
    --with-libssh2="/usr/local" \
    --with-nghttp2="/usr/local" \
    --with-ca-bundle="/usr/local/share/curl/cacert.pem" \
    --without-gnutls \
    --without-libidn \
    --with-ldap-lib=ldap \
    --with-lber-lib=no \
    --without-libmetalink \
    CPP="${GCC}/bin/cpp-8" \
    CC="${GCC}/bin/gcc-8" \
    CFLAGS="-O2 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
    CPPFLAGS="-I${SSL}/include -I/usr/local/include -I/usr/include" \
    LDFLAGS="-L${SSL}/lib -L/usr/local/lib -L/usr/lib"
make
export LANG=ja_JP.UTF-8
make check >check.log

注)「¥」は実際には半角の「\」(バックスラッシュ)


< 過去の記事 [ 10月の 自宅サーバ リスト ] 新しい記事 >

2019 calendar
10月
12345
6789101112
13141516171819
20212223242526
2728293031


掲示板
最新:08/15 17:19


GsBlog was developed by GUSTAV, Copyright(C) 2003, Web Application Factory All Rights Reserved.