Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3693063
  • 博文数量: 356
  • 博客积分: 10458
  • 博客等级: 上将
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-24 14:59
文章分类

全部博文(356)

文章存档

2020年(12)

2019年(9)

2018年(26)

2017年(5)

2016年(11)

2015年(20)

2014年(2)

2013年(17)

2012年(15)

2011年(4)

2010年(7)

2009年(14)

2008年(209)

分类: LINUX

2019-01-23 21:27:46

下载nghttp2代码
https://github.com/nghttp2/nghttp2/releases
解压代码, 比如解压到/home/zm/download/nghttp2-1.36.0,进入代码目录,进行编译
./configure --enable-lib-only --host=arm-openwrt-linux --prefix=/opt/test/thirdparty/install/
make
make install

下载curl代码
https://curl.haxx.se/download.html
或者
https://curl.haxx.se/download/?C=M;O=D
解压后,进入代码目录

假设其他的依赖库放在/opt/test/thirdparty/install/下,包括ssl cares 等库
生成Makefile
PKG_CONFIG_PATH="/opt/test/thirdparty/install/lib/pkgconfig" \
./configure --host=arm-openwrt-linux --enable-ares --enable-http --enable-ipv6 --enable-pthreads --enable-cookies --with-nghttp2=/opt/test/thirdparty/install  CPPFLAGS="-I/opt/test/thirdparty/install/include"  LDFLAGS="-L/opt/test/thirdparty/install/lib" LIBS="-L/opt/test/thirdparty/install/lib" --prefix=`pwd`/install

修改Makefile
src/Makefile
1) CCLD = $(CC) 改成 CCLD = $(CC) $(LIBCURL_LIBS)
不改CCLD会出现
../lib/.libs/libcurl.so: undefined reference to `EVP_MD_CTX_free@OPENSSL_1_1_0'
../lib/.libs/libcurl.so: undefined reference to `X509_EXTENSION_get_object@OPENSSL_1_1_0'
的错误

改完后开始编译:
make
make install

测试是否支持http2
curl -v -k --http2 https://www.xdty.org

如果打印如下说明编译出来的curl不支持http2
curl: (1) Unsupported protocol

以下为正常的打印
root@(none):/# curl -v -k --http2 https://www.xdty.org
*   Trying 54.95.68.178...
* TCP_NODELAY set
* Connected to www.xdty.org (54.95.68.178) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=xdty.org
*  start date: Dec 14 10:16:39 2018 GMT
*  expire date: Mar 14 10:16:39 2019 GMT
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* 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 0x79e788)
> GET / HTTP/2
> Host: www.xdty.org
> User-Agent: curl/7.63.0
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200

作者:帅得不敢出门   c++哈哈堂:31843264

阅读(1114) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~