2016-04-04 42 views
1

我對這些工具不是很有經驗,所以請耐心等待。我想從源中使用SSL構建curl。要做到這一點,我也從源代碼編譯OpenSSL建築捲曲源 - 未定義參考SSL_CTX_set_alpn_protos

構建並安裝OpenSSL後,會創建一個存檔文件。這個焦油然後被解開,並應該在建造curl時使用。

的方式我做它:

OpenSSL的

./config shared -fPIC --prefix="/some/path/install_dir" 
make depend 
make && make install 

rm -rf /some/path/install_dir/lib/pkgconfig 
# create tar from $prefix/bin $prefix/include $prefix/lib 

pkgconfig被刪除,因爲當我離開那裏它包含了絕對路徑OpenSSL的建設機器上的圖書館,這可能與捲曲機器不同,我只想使用檔案中的那些。 我不知道這是否是一種正確的方法。

捲曲

來自前一步驟的存檔被複制和解壓。然後

export LIBS='-ldl' 
./configure --prefix="$(pwd)/<install_dir>" --with-ssl="<unpacked-tar>" 
make && make install 

然而,make結果:

../lib/.libs/libcurl.so: undefined reference to `SSL_CTX_set_alpn_protos' 
../lib/.libs/libcurl.so: undefined reference to `SSL_get0_alpn_selected' 

建設既OpenSSL和捲曲在同一個(測試)機的工作原理。使用openssl-1.0.2gcurl-7.47.1。任何想法可能是錯誤的?


捲曲的的config.log包含編譯命令是這樣的:

gcc -o conftest -O2 -Wno-system-headers -I/home/teamcity/buildAgent/work/10199cb4c61825f3/openssl-1.0.2g/include -I/home/teamcity/buildAgent/work/10199cb4c61825f3/openssl-1.0.2g/include/openssl -L/home/teamcity/buildAgent/work/10199cb4c61825f3/openssl-1.0.2g/lib conftest.c -lcrypto -lz -lrt -ldl >&5 

-I文件夾是我要包含的那些,所以我覺得全系統庫應不被使用。

正在搜索NPNPROT未產生任何結果,因此未禁用協商。

回答

1

從前面步驟的存檔複製並解壓 ... 建設既OpenSSL和捲曲在同一個(測試)機的工作原理。

這聽起來像OpenSSL的生成計算機上啓用了下一步協議協商,但目標機器的OpenSSL的建沒有下一頁協議協商。對於OpenSSL 1.1.0,我相信這意味着構建機器配置了no-nextprotoneg。對於OpenSSL 1.0.2及更低版本,我相信這意味着它被配置爲no-npn


SSL_CTX_set_alpn_protos是OpenSSL 1.1.0的一部分。該.pod是很重要的,因爲這意味着它的記載,所以它意味着一個公共職能由用戶程序調用(這是一個1.1.0政策變化):在1.0.2

$ cd openssl-master 
$ grep -IR SSL_CTX_set_alpn_protos * | egrep '(ssl.h|.pod)' 
doc/ssl/SSL_CTX_set_alpn_select_cb.pod:SSL_CTX_set_alpn_protos, SSL_set_alpn_protos, SSL_CTX_set_alpn_select_cb, 
doc/ssl/SSL_CTX_set_alpn_select_cb.pod: int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, 
doc/ssl/SSL_CTX_set_alpn_select_cb.pod:SSL_CTX_set_alpn_protos() and SSL_set_alpn_protos() are used by the client to 
doc/ssl/SSL_CTX_set_alpn_select_cb.pod:SSL_CTX_set_alpn_protos() and SSL_set_alpn_protos() return 0 on success, and 
include/openssl/ssl.h:__owur int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, 

其還提供:

$ cd openssl-1.0.2g 
$ grep -IR SSL_CTX_set_alpn_protos * 
apps/s_client.c:  SSL_CTX_set_alpn_protos(ctx, alpn, alpn_len); 
ssl/ssl.h:int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, 
ssl/ssl_lib.c: * SSL_CTX_set_alpn_protos sets the ALPN protocol list on |ctx| to |protos|. 
ssl/ssl_lib.c:int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, 
ssl/ssltest.c:  SSL_CTX_set_alpn_protos(c_ctx, alpn, alpn_len); 
util/ssleay.num:SSL_CTX_set_alpn_protos     387 EXIST::FUNCTION: 

我的猜測是捲曲使用下級,發行提供的OpenSSL缺乏協議談判(如OpenSSL的0.9.8):

export LIBS='-ldl' 
./configure --prefix="$(pwd)/<install_dir>" --with-ssl="<unpacked-tar>" 
make && make install 

檢查config.log以查看配置過程中發現的捲曲。


可以在OpenSSL的關閉協議的談判與:

  • OpenSSL的1.0.2 - no-npn
  • OpenSSL的1.1.0 - no-nextprotoneg

它將<openssl/opensslconf.h顯示:

$ cd openssl-master 
$ ./config no-nextprotoneg 
... 

$ find $PWD -name 'opensslconf.h' 
.../include/openssl/opensslconf.h 
$ cat .../include/openssl/opensslconf.h | grep PROT 
#ifndef OPENSSL_NO_NEXTPROTONEG 
# define OPENSSL_NO_NEXTPROTONEG 

和:

$ cd openssl-1.0.2g 
$ ./config no-npn 
... 

$ cat include/openssl/opensslconf.h | grep NPN 
#ifndef OPENSSL_NO_NPN 
# define OPENSSL_NO_NPN 
# if defined(OPENSSL_NO_NPN) && !defined(NO_NPN) 
# define NO_NPN 

所以,你也應該確認它沒有在構建時禁用。


它看起來像捲曲不完全同情no-npnno-nextprotoneg

$ git clone https://github.com/curl/curl.git 
$ cd curl/ 
$ egrep -IR '(OPENSSL_NO_NPN|OPENSSL_NO_NEXTPROTONEG)' * 
lib/vtls/openssl.c: && !defined(OPENSSL_NO_NEXTPROTONEG) 

這也是爲SSL_CTX_set_alpn_protos唯一命中:

$ grep -IR SSL_CTX_set_alpn_protos * 
lib/vtls/openssl.c: SSL_CTX_set_alpn_protos(connssl->ctx, protocols, cur) 
+0

編輯的問題。從config.log來看,它看起來和預期的一樣。協議協商看起來不被禁用 –