最近在研究QUIC協定,嘗試了一些QUIC相關的開源項目,主要是c,c++,go等語言編寫的。這裡記錄下我折騰ngtcp2的過程。
基本思路就是參照github上該項目的README來進行就可以了。由于是Ubuntu 16.04,很多依賴基本上都滿足了,比如gcc版本是5.4.0。QUIC依賴的TLS 1.3是安裝在openssl的源碼目錄下面,沒有安裝到系統庫中,這一點使用時比較友善。
git clone --depth 1 https://github.com/openssl/openssl
cd openssl
./config enable-tls1_3 --prefix=$PWD/build
make -j$(nproc)
make install_sw
cd ..
git clone https://github.com/ngtcp2/ngtcp2
cd ngtcp2
autoreconf -i
./configure PKG_CONFIG_PATH=$PWD/../openssl/build/lib/pkgconfig LDFLAGS="-Wl,-rpath,$PWD/../openssl/build/lib"
make -j$(nproc) check
生成證書和密鑰
cd examples
openssl genrsa -out server.key 2048
openssl req -new -x509 -key server.key -out server.crt -days 3650
打開兩個終端,分别開啟client和server
./client 127.0.0.1 4433 -i
./server 127.0.0.1 4433 server.key server.crt
所有操作過程和項目README上的完全相同。
參考文獻
[1].https://github.com/ngtcp2/ngtcp2