草 稿

OpenConnect 编译笔记

网络上有很多 OpenConnect 配置的文章,但是都比较老了,最新版本的 ocserv 的一些新功能(如 no-route )都没有被发挥出来,手动在老服务器系统上编译一遍,留下一些笔记,以飨各位热爱自由的同仁。

  1. 准备工作

  2. 解决依赖

    服务器环境 CentOS release 6.7 (Final)

     

    $sudo yum install gmp gmp-devel libnl libnl3 readline liboath

  3. 下载软件

  4. nettle

    $wget https://ftp.gnu.org/gnu/nettle/nettle-3.2.tar.gz

     

    $wget https://ftp.gnu.org/gnu/nettle/nettle-3.2.tar.gz.sig

     

    $gpg --keyserver pgp.mit.edu --search-keys 0x28C67298

     

    按提示导入开发者 Niels Möller 的 GPG 公钥

     

    $gpg --verify nettle-3.2.tar.gz.sig

     

    签名正确才能继续。

  5. Unbound

    $wget https://unbound.net/downloads/unbound-latest.tar.gz

     

    $wget https://unbound.net/downloads/unbound-1.5.8.tar.gz.asc

     

    $gpg --keyserver pgp.mit.edu --search-keys 0x7E045F8D

     

    按提示导入开发者 W.C.A. Wijngaards 的 GPG 公钥

     

    $gpg --verify unbound-1.5.8.tar.gz.asc

     

    签名正确才能继续。

  6. Libtasn1

    $wget -c https://ftp.gnu.org/gnu/libtasn1/libtasn1-4.7.tar.gz

     

    $wget -c https://ftp.gnu.org/gnu/libtasn1/libtasn1-4.7.tar.gz.sig

     

    $curl http://members.hellug.gr/nmav/pgpkeys.asc | gpg --import

     

    按提示导入开发者 Nikos Mavrogiannopoulos 的 GPG 公钥

     

    $gpg --verify libtasn1-4.7.tar.gz.sig

     

    签名正确才能继续。

  7. GnuTLS

    $wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.4/gnutls-3.4.9.tar.xz

     

    $wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.4/gnutls-3.4.9.tar.xz.sig

     

    仍然用 Nikos Mavrogiannopoulos 的 GPG 公钥来验证签名

     

    $gpg --verify gnutls-3.4.9.tar.xz.sig

     

    签名正确才能继续。

  8. libev4

    yum 方式安装的 libev 不能用,只好手动编译了。

     

    $wget http://dist.schmorp.de/libev/libev-4.22.tar.gz

     

    暂无签名

  9. OpenConnect VPN Server (ocserv)

    $wget ftp://ftp.infradead.org/pub/ocserv/ocserv-0.11.0rc1.tar.xz

     

    $wget ftp://ftp.infradead.org/pub/ocserv/ocserv-0.11.0rc1.tar.xz.sig

     

    仍然用 Nikos Mavrogiannopoulos 的 GPG 公钥来验证签名

     

    $gpg --verify ocserv-0.11.0rc1.tar.xz.sig

     

    签名正确才能继续。

     

    注意,早期的包用的不是这个 GPG 公钥签的,所以这里下载的是 ocserv-0.11.0rc1.tar.xz 。

  10. 编译 nettle

    $tar xzvf nettle-3.2.tar.gz && cd nettle-3.2

     

    $sudo ./configure --prefix=/usr && make && sudo make install

     

    $sudo chmod -v 755 /usr/lib64/libhogweed.so.4.2 /usr/lib64/libnettle.so.6.2 /usr/lib64/libnettle.a

     

    $cd -

  11. 编译 Unbound

    $tar xzvf unbound-1.5.8.tar.gz && cd unbound

     

    $./configure && make && sudo make install

     

    $sudo mkdir -p /etc/unbound && sudo /usr/local/sbin/unbound-anchor -a "/etc/unbound/root.key"

     

    $cd -

  12. 编译 Libtasn1

    $tar xzvf libtasn1-4.7.tar.gz && cd libtasn1-4.7

     

    $./configure && make && sudo make install

     

    $cd -

  13. 编译 GnuTLS

    $tar xvf gnutls-3.4.9.tar.xz && cd gnutls-3.4.9

     

    $./configure --with-included-libtasn1 --without-p11-kit && make && sudo make install

     

    $cd -

  14. 编译 libev4

    $tar xzvf libev-4.22.tar.gz && cd libev-4.22

     

    $.configure && make && sudo make install

     

    $cd -

  15. 编译 ocserv

    修改环境变量

     

    $export LD_LIBRARY_PATH=/usr/lib/:/usr/lib64/ NETTLE_CFLAGS="-I /usr/include/" NETTLE_LIBS="-L /usr/lib64/ -l nettle" HOGWEED_CFLAGS="-I /usr/include" HOGWEED_LIBS="-L /usr/lib64/ -l hogweed"

     

    $export LD_LIBRARY_PATH=/usr/lib/:/usr/lib64/ LIBGNUTLS_CFLAGS="-I /usr/include/" LIBGNUTLS_LIBS="-L /usr/lib/ -l gnutls" LIBNL3_CFLAGS="-I /usr/include" LIBNL3_LIBS="-L /usr/lib/ -l nl-3 -lnl-route-3"

     

    $tar xvf ocserv-0.11.0rc1.tar.xz && cd ocserv-0.11.0rc1

     

    $cp -R libopts/ src/

     

    $cp -R src/protobuf/protobuf-c/ src/protobuf-c/

     

    上面这两个文件夹要改一下位置,不然 make 不过

     

    $./configure --without-protobuf && make && sudo make install

     

    $cd -

  16. 配置

  17. 签证书

  18. 配置 ocserv.conf

    编译的是最新版,所以直接用 ocserv-cn-no-route 路由表,绕过中国大陆地址。

率先点赞

评论(0