当前位置: 首页 > 科技观察

Nginx+LibreSSL:早期采用者测试

时间:2023-03-12 20:15:33 科技观察

tl;dr:使用LibreSSL的第2晚......仍然工作正常7月11日,LibreSSL团队发布了可移植、Linux、OSX、Solaris和FreeBSD版本。[1,2,5,8]本文将介绍一些结合Libressl使用Nginx的实践经验。本文使用的软件版本为nginx1.6.0libressl2.0.0在reddit-discussion[11]中描述了使用最新开发版本(1.7分支)会出现的一些问题。安装直接从源代码编译LibreSSL。构建过程的输出非常简洁。源代码还附带测试用例并提供并行构建支持(参见附录)。#构建安装libressl的选项[7]$./configure--prefix=/usrLDFLAGS=-lrt&&makecheck&&sudomakeinstall新安装的LibreSSL可以替代openssl以同样的方式运行,但是要注意:assabotage-linux的spencerjohn和GentooAsHanno的博克。[3,4]LibreSSL会报告其版本为LibreSSL2.0,openssl命令的使用方法与openssl一样:$whichopenssl/usr/bin/openssl$opensslversionLibreSSL2.0$openssls_client-hostwww.openssl.org-port4430000(030CONNECTED)=2C=BE,O=GlobalSignnv-sa,OU=RootCA,CN=GlobalSignRootCAverifyerror:num=19:selfsignedcertificateincertificatechainverifyreturn:0---Certificatechain0s:/C=GB/OU=DomainControlValidated/CN=*.openssl.orgi:/C=BE/O=GlobalSignnv-sa/CN=GlobalSignDomainValidationCA-G21s:/C=BE/O=GlobalSignnv-sa/OU=RootCA/CN=GlobalSignRootCAi:/C=BE/O=GlobalSignnv-sa/OU=RootCA/CN=GlobalSignRootCA2s:/C=BE/O=GlobalSignnv-sa/CN=GlobalSignDomainValidationCA-G2i:/C=BE/O=GlobalSignnv-sa/OU=RootCA/CN=GlobalSignRootCA---服务器证书-----BEGINCERTIFICATE-----...skip-----ENDCERTIFICATE-----subject=/C=GB/OU=DomainControlValidated/CN=*.openssl.orgissuer=/C=BE/O=GlobalSignnv-sa/CN=GlobalSignDomainValidationCA-G2---NoclientcertificateCAnamessent---SSLhandshakehasread4136bytesandwritten707bytes---新的,TLSv1/SSLv3,CipherisDHE-RSA-AES256-GCM-SHA384Serverpublickeyis2048bitSecureRenegotiationISsupportedCompression:NONEExpansion:NONESSL-Session:Protocol:TLSv1.2Cipher:DHE-RSA-AES256-GCM-SHA384Tseconds)TLSsessionticket:在确认libressl工作后,我让nginx使用libressl,尽管在仍然使用openssl0.9.x的遗留系统上,我通常静态构建nginx+openssl以获得最新和最好的tls版本。第一次尝试,仅仅使用./configure--with-openssl=/path/to/libressl将是一个很大的错误,因为nginx完全集成到openssl构建过程中:使用名为./config的脚本来替换./configure(容易解决)openssl会收集.openssl/lib下的objects(.obj)文件和其他文件链接成二进制文件和库文件,而libressl会把这些文件分别存放在crypto/.libs和ssl/下。库。尝试通过手动设置目录层次结构(.openssl/lib)并根据libressl构建成功后出现的错误信息(见下面的错误信息)复制文件来解决这些问题;LDFLAGS=-lrt选项解决了问题的报错信息,但是在尝试编译nginx和链接到已经静态编译的libressl库时还是不能解决问题(不过我还是继续):...objs/addon/nginx-upstream-fair/ngx_http_upstream_fair_module.o\objs/addon/src/ngx_http_headers_more_filter_module.o\objs/addon/src/ngx_http_headers_more_headers_out.o\objs/addon/src/ngx_http_headers_more_headers_in.o\objs/addon/src/ngx_addonmo/src/ngx_http_encrypted_session_module.o\objs/addon/src/ngx_http_encrypted_session_cipher.o\objs/ngx_modules.o\-Wl,-E-lpthread-lcrypt-L/usr/lib-lm-llua5.1-lpcre/data/builds/froggstack/nginx_modules/openssl/.openssl/lib/libssl.a/data/builds/froggstack/nginx_modules/openssl/.openssl/lib/libcrypto.a-ldl-lz/data/builds/froggstack/nginx_modules/openssl/。openssl/lib/libcrypto.a(libcompat_la-getentropy_linux.o):Infunction`getentropy_fallback':/data/builds/froggstack/nginx_modules/openssl/crypto/compat/getentropy_linux.c:324:未定义对“clock_gettime”的引用/data/builds/froggstack/nginx_modules/openssl/crypto/compat/getentropy_linux.c:395:未定义对“clock_gettime”的引用collect2:error:ldreturned1exitstatusmake[1]:***[objs/nginx]Error1make[1]:Leavingdirectory`/data/builds/froggstack/src_nginx/nginx-1.6.0'make:***[build]Error2下一次尝试是通过安装了libressl链接libressl的动态库构建nginx,终于成功了(完整的nginx./configure选项参数见附录)运行nginx-libressl-t测试成功,将/usr/bin/nginx替换为新的二进制可执行文件和运行/etc/init.d/nginxrestart,更新后的nginx+libressl生效。nginx的任何配置文件和ssl配置都不需要修改,很好!有兴趣测试想测试的朋友可以访问:www.mare-system.de,网站从2014-07-12开始运行在libressl上。如果您发现任何不兼容问题,请发送消息至atsecurity@mare-system.de。在各种Linux和Android浏览器上测试没有问题;即使在一个被遗忘的2007年10月发布的带有OpenSSL0.9.8g19的debian5上,使用w3m之类的东西已经过时了,在控制台浏览器上浏览也没有问题。在ssllabs.com上测试,得分为A+,与之前的配置相同;使用libressl后,唯一给出的提示是加密算法ChaCha20-Poly1305仍处于实验阶段。做了一点性能测试,发现没有大问题;LibreSSL比平均速度慢4%。原因可能是openssl是静态链接nginx的,而libressl是动态链接nginx的,所以会产生更多的资源开销。纯数测试结果:|ParallelRequests|OpenSSL-RPS|LibreSSL-RPS|10|2341.75|2260.5|20|2459.75|2418.25|30|2472|2397|40|2485|2384.5|50|2445|2382.25|60|2453.25|2390.75|70|2426.25|2347.25|80|2346.5|2227.5|90|2325.5|2211|100|2297.75|2318.25有关如何测试性能的一些描述可以在附录中找到。#p#结论这个方法是可行的。虽然现阶段不建议使用LibreSSL代替OpenSSL,但我只是想测试一下它的可行性。事实证明这是有效的。从我的测试来看,没有功能或性能问题,构建nginx+libressl很容易,只要你弄清楚如何去做。在我看来,使用LibreSSL的长期好处是:干净的代码更少的错误更多的人参与当我写这篇文章时,我听说新的LibreSSL版本已经发布,解决了一些新问题。所以,回到OpenSSL似乎有点不合理:干得好,LibreSSL团队,再次感谢您发布LibreSSL参考第一个可移植的LibreSSL版本-下载libreSSL的兼容性如何?UsingLibreSSLonGentooLibreSSL'sgithubrepositoryNginx+SSL+SPDYGuideTroubleshootingLibreSSLonRedhatLibreSSL-HomeSSLReport:mare-system.deSecondPortableLibreSSLReleaseReddit-discussionNginx+BoringSSLAppendixSSL配置和加密算法使用服务器{listen443sslspdy;server_namewww.mare-system.de;...#sslssl_session_cacheshared:SSL:10m;ssl_session_timeout10m;#olderprotosforbrowsercompatibilityssl_protocolsTLSv1TLSv1.1TLSv1.2;ssl_prefer_server_cipherson;#suggestionfromsslabs/包括PFSssl_ciphersEECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS;#excludingsubDomainonpurposeadd_headerStrict-Transport-Security"max-age=31536000";...}Nginx用于动态链接到LibreSSL的Configure选项nginx_libressl_opts="""--conf-path=/etc/nginx/nginx.conf--sbin-path=/usr/sbin/nginx--prefix=--error-log-path=/var/log/nginx/error.log--http-log-path=/var/log/nginx/access.log--http-client-body-temp-path=/var/运行/nginx/client_temp--http-proxy-temp-path=/var/run/nginx/proxy_temp--http-fastcgi-temp-path=/var/run/nginx/fastcgi_temp--with-file-aio--with-http_gzip_static_module--with-http_ssl_module--with-http_spdy_module--with-http_stub_status_module--with-debug--without-mail_pop3_module--without-mail_smtp_module--without-mail_imap_module--without-http_uwsgi_module--without-http_scgi_module--没有-http_ssi_module--add-module=$nmd/nginx-openssl-version--add-module=$nmd/naxsi--add-module=$nmd/lua-nginx-module--add-module=$nmd/ngx_devel_kit--add-module=$nmd/echo-nginx-module--add-module=$nmd/nginx-accesskey--add-module=$nmd/ngx_http_log_request_speed--add-module=$nmd/set-misc-nginx-module--add-module=$nmd/nginx-sticky-module-ng--add-module=$nmd/ngx_cache_purge--add-module=$nmd/memc-nginx-module--add-module=$nmd/nginx-upstream-fair--add-module=$nmd/headers-more-nginx-module--add-module=$nmd/encrypted-session-nginx-moduleLibreSSL-编译时间和输出=================================================================Libressl2.0.0的测试套件摘要=================================================================================#TOTAL:41#PASS:41#SKIP:0#XFAIL:0#FAIL:0#XPASS:0#ERROR:0=================================================================================性能测试方法小型服务器,双核,2GB内存,无特殊调整从另一台服务器发起性能测试,使用automakeab(abmeter)脚本打开keepaliveurl:/(由nginx缓存)测试10,20,30...100个并发连接,每个配置100.000个请求测试4轮累积结果/4->每次运行的值OpenSSLValhallaRampagehttps://www.ssllabs.com/ssltest/analyze.html?d=mare-system.deEnglish原文:Nginx+LibreSSL-afirsttest翻译链接:http://www.oschina.net/translate/nginx-libressl-first-test