Skip to content

Commit 1f8cb95

Browse files
committed
修复windows上curl TLCP无法使用的问题
windows上使用nmake构建,和Linux构建脚本不一样,增加NTLS相关编译选项; 同步curl最新代码,重新适配。
1 parent b032cbe commit 1f8cb95

File tree

8 files changed

+1016
-871
lines changed

8 files changed

+1016
-871
lines changed

.github/scripts/spacecheck.pl

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"\\.(bat|sln|vc)\$",
3434
"^tests/certs/.+\\.der\$",
3535
"^tests/data/test",
36+
"tongsuo.patch",
3637
);
3738

3839
my @mixed_eol = (
@@ -49,6 +50,7 @@
4950
my @space_at_eol = (
5051
"^tests/.+\\.(cacert|crt|pem)\$",
5152
"^tests/data/test",
53+
"tongsuo.patch",
5254
);
5355

5456
my @eol_at_eof = (

.github/workflows/release.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
name: release
66

7-
on:
7+
'on':
88
workflow_dispatch:
99
tags:
1010
- '*'
@@ -43,11 +43,11 @@ jobs:
4343
if: ${{ matrix.builder == 'macos-latest' }}
4444
- name: build Tongsuo
4545
run: |
46-
VERSION=8.3.3
46+
VERSION=8.4.0
4747
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${VERSION}.tar.gz"
4848
tar zxf "${VERSION}.tar.gz"
4949
pushd "Tongsuo-${VERSION}"
50-
./config --prefix=${GITHUB_WORKSPACE}/tongsuo no-shared enable-ntls --release
50+
./config --prefix=${GITHUB_WORKSPACE}/tongsuo no-shared enable-ntls enable-ssl-trace --release
5151
make -s -j4
5252
make install_sw
5353
popd
@@ -62,7 +62,6 @@ jobs:
6262
autoreconf -fi
6363
./configure --enable-warnings --enable-werror --with-openssl=${GITHUB_WORKSPACE}/tongsuo --without-zlib --without-brotli --disable-shared --disable-ldap --disable-ldaps --disable-rtsp --without-librtmp --enable-static
6464
make -s -j4
65-
6665
- name: upload artifact
6766
uses: actions/upload-release-asset@v1
6867
env:
@@ -88,7 +87,7 @@ jobs:
8887
- name: Export env
8988
shell: bash
9089
run: |
91-
VERSION=8.3.3
90+
VERSION=8.4.0
9291
echo "TONGSUO_VERSION=${VERSION}" >> $GITHUB_ENV
9392
echo "TONGSUO_HOME=${GITHUB_WORKSPACE}\tongsuo${VERSION}" >> $GITHUB_ENV
9493
- name: Download Tongsuo source
@@ -103,7 +102,7 @@ jobs:
103102
pushd "Tongsuo-%TONGSUO_VERSION%"
104103
mkdir _build
105104
pushd _build
106-
perl ..\Configure no-makedepend no-shared VC-WIN64A --prefix=%TONGSUO_HOME%
105+
perl ..\Configure no-makedepend no-shared enable-ntls enable-ssl-trace VC-WIN64A --prefix=%TONGSUO_HOME% --release
107106
nmake /S
108107
nmake install_sw
109108
popd
@@ -119,7 +118,9 @@ jobs:
119118
git apply tongsuo.diff
120119
./buildconf.bat
121120
cd winbuild
122-
nmake /f Makefile.vc mode=static WITH_SSL=static SSL_PATH=${env:TONGSUO_HOME} RTLIBCFG=static
121+
nmake /f Makefile.vc mode=static WITH_SSL=static SSL_PATH=${env:TONGSUO_HOME} RTLIBCFG=static ENABLE_NTLS=yes
122+
cd ..
123+
builds\libcurl-vc-x64-release-static-ssl-static-ipv6-sspi\bin\curl.exe --help tls | findstr tlcp
123124
- name: upload artifact
124125
uses: actions/upload-release-asset@v1
125126
env:

.github/workflows/reuse.yml

-33
This file was deleted.

.github/workflows/tongsuo.yml

+72-18
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,90 @@
44

55
name: build-with-tongsuo
66

7-
on: [workflow_dispatch, pull_request, push]
7+
'on': [workflow_dispatch, pull_request, push]
88

99
jobs:
10-
autotools:
11-
runs-on: 'ubuntu-latest'
12-
timeout-minutes: 60
13-
10+
build_linux_macos:
11+
runs-on: ${{ matrix.builder }}
12+
strategy:
13+
matrix:
14+
builder: [macos-latest, ubuntu-latest]
15+
name: "build-${{ matrix.builder }}"
1416
steps:
15-
- name: checkout tongsuo
16-
uses: actions/checkout@v2
17-
with:
18-
repository: Tongsuo-Project/Tongsuo
19-
path: Tongsuo
20-
- name: install Tongsuo
21-
working-directory: ./Tongsuo
17+
- run: |
18+
brew install libtool autoconf automake pkg-config
19+
if: ${{ matrix.builder == 'macos-latest' }}
20+
- name: build Tongsuo
2221
run: |
23-
./config --banner=Configured --prefix=${GITHUB_WORKSPACE}/install enable-ntls
22+
VERSION=8.4.0
23+
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${VERSION}.tar.gz"
24+
tar zxf "${VERSION}.tar.gz"
25+
pushd "Tongsuo-${VERSION}"
26+
./config --prefix=${GITHUB_WORKSPACE}/tongsuo no-shared enable-ntls enable-ssl-trace --release
2427
make -s -j4
25-
make install
26-
- uses: actions/checkout@v3
28+
make install_sw
29+
popd
30+
- uses: actions/checkout@v2
2731
with:
2832
path: curl
29-
33+
fetch-depth: 0
3034
- name: build curl
3135
working-directory: ./curl
3236
run: |
3337
git apply tongsuo.patch
3438
autoreconf -fi
35-
LDFLAGS=-Wl,-rpath=${GITHUB_WORKSPACE}/install/lib64/ ./configure --enable-warnings --enable-werror --with-openssl=${GITHUB_WORKSPACE}/install
36-
make V=1
39+
./configure --enable-warnings --enable-werror --with-openssl=${GITHUB_WORKSPACE}/tongsuo --without-zlib --without-brotli --disable-shared --disable-ldap --disable-ldaps --disable-rtsp --without-librtmp --without-libpsl --enable-static
40+
make -s -j4
3741
make V=1 examples
3842
make V=1 -C tests
3943
make V=1 test-ci
44+
./src/curl --help tls | grep tlcp
45+
46+
build_windows:
47+
runs-on: windows-latest
48+
steps:
49+
- run: choco install -y winrar
50+
- uses: ilammy/msvc-dev-cmd@v1
51+
with:
52+
arch: win64
53+
- uses: ilammy/setup-nasm@v1
54+
with:
55+
platform: win64
56+
- uses: shogo82148/actions-setup-perl@v1
57+
- name: Export env
58+
shell: bash
59+
run: |
60+
VERSION=8.4.0
61+
echo "TONGSUO_VERSION=${VERSION}" >> $GITHUB_ENV
62+
echo "TONGSUO_HOME=${GITHUB_WORKSPACE}\tongsuo${VERSION}" >> $GITHUB_ENV
63+
- name: Download Tongsuo source
64+
run: |
65+
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${env:TONGSUO_VERSION}.tar.gz" -OutFile "${env:TONGSUO_VERSION}.tar.gz"
66+
shell: powershell
67+
- run: '"C:\Program Files\WinRAR\WinRAR.exe" -INUL x %TONGSUO_VERSION%.tar.gz'
68+
shell: cmd
69+
- name: Build Tongsuo
70+
shell: cmd
71+
run: |
72+
pushd "Tongsuo-%TONGSUO_VERSION%"
73+
mkdir _build
74+
pushd _build
75+
perl ..\Configure no-makedepend no-shared enable-ntls enable-ssl-trace VC-WIN64A --prefix=%TONGSUO_HOME% --release
76+
nmake /S
77+
nmake install_sw
78+
popd
79+
popd
80+
- uses: actions/checkout@v2
81+
with:
82+
path: curl
83+
fetch-depth: 0
84+
- name: build curl
85+
working-directory: ./curl
86+
shell: powershell
87+
run: |
88+
git apply tongsuo.diff
89+
./buildconf.bat
90+
cd winbuild
91+
nmake /f Makefile.vc mode=static WITH_SSL=static SSL_PATH=${env:TONGSUO_HOME} RTLIBCFG=static ENABLE_NTLS=yes
92+
cd ..
93+
builds\libcurl-vc-x64-release-static-ssl-static-ipv6-sspi\bin\curl.exe --help tls | findstr tlcp

Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ PLAN9_DIST = plan9/include/mkfile \
8383

8484
EXTRA_DIST = CHANGES.md COPYING Makefile.dist \
8585
RELEASE-NOTES $(CMAKE_DIST) $(VC_DIST) $(WINBUILD_DIST) \
86-
$(PLAN9_DIST) buildconf.bat Dockerfile
86+
$(PLAN9_DIST) buildconf.bat Dockerfile tongsuo.patch
8787

8888
CLEANFILES = $(VC14_LIBVCXPROJ) $(VC14_SRCVCXPROJ) \
8989
$(VC14_10_LIBVCXPROJ) $(VC14_10_SRCVCXPROJ) \

docs/examples/https-tlcp-doublecerts.c

+28-24
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,40 @@
2828
#include <stdio.h>
2929
#include <curl/curl.h>
3030

31-
int main(int argc, char **argv)
31+
int main(void)
3232
{
33-
CURL *curl;
34-
CURLcode res;
33+
CURL *curl;
34+
CURLcode res;
3535

36-
curl = curl_easy_init();
37-
if (curl) {
38-
curl_easy_setopt(curl, CURLOPT_URL, "https://127.0.0.1:443");
39-
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_NTLSv1_1);
40-
curl_easy_setopt(curl, CURLOPT_SSL_CIPHER_LIST,
41-
"ECDHE-SM2-SM4-CBC-SM3");
36+
curl = curl_easy_init();
37+
if(curl) {
38+
curl_easy_setopt(curl, CURLOPT_URL, "https://127.0.0.1:443");
39+
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_NTLSv1_1);
40+
curl_easy_setopt(curl, CURLOPT_SSL_CIPHER_LIST,
41+
"ECDHE-SM2-SM4-CBC-SM3");
4242

43-
curl_easy_setopt(curl, CURLOPT_SSLSIGNCERT, "sm2_sign.crt");
44-
curl_easy_setopt(curl, CURLOPT_SSLSIGNKEY, "sm2_sign.key");
45-
curl_easy_setopt(curl, CURLOPT_SSLENCCERT, "sm2_enc.crt");
46-
curl_easy_setopt(curl, CURLOPT_SSLENCKEY, "sm2_enc.key");
43+
curl_easy_setopt(curl, CURLOPT_SSLSIGNCERT, "sm2_sign.crt");
44+
curl_easy_setopt(curl, CURLOPT_SSLSIGNKEY, "sm2_sign.key");
45+
curl_easy_setopt(curl, CURLOPT_SSLENCCERT, "sm2_enc.crt");
46+
curl_easy_setopt(curl, CURLOPT_SSLENCKEY, "sm2_enc.key");
4747

48-
/* optional */
49-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
50-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
48+
/* optional */
49+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
50+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
5151

52-
res = curl_easy_perform(curl);
52+
res = curl_easy_perform(curl);
5353

54-
if(res != CURLE_OK)
55-
fprintf(stderr, "curl_easy_perform() failed: %s\n",
56-
curl_easy_strerror(res));
54+
if(res != CURLE_OK)
55+
fprintf(stderr, "curl_easy_perform() failed: %s\n",
56+
curl_easy_strerror(res));
5757

58-
curl_easy_cleanup(curl);
59-
}
58+
curl_easy_cleanup(curl);
59+
}
6060

61-
return 0;
61+
return 0;
6262
}
63-
// gcc https-tlcp-doublecerts.c -o https-tlcp-doublecerts -I/usr/local/curl/include -lcurl -L/usr/local/curl/lib -Wl,-rpath=/usr/local/curl/lib
63+
/*
64+
gcc https-tlcp-doublecerts.c -o https-tlcp-doublecerts \
65+
-I/usr/local/curl/include -lcurl -L/usr/local/curl/lib \
66+
-Wl,-rpath=/usr/local/curl/lib
67+
*/

docs/examples/https-tlcp.c

+22-19
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,33 @@
2828
#include <stdio.h>
2929
#include <curl/curl.h>
3030

31-
int main(int argc, char **argv)
31+
int main(void)
3232
{
33-
CURL *curl;
34-
CURLcode res;
33+
CURL *curl;
34+
CURLcode res;
3535

36-
curl = curl_easy_init();
37-
if (curl) {
38-
curl_easy_setopt(curl, CURLOPT_URL, "https://127.0.0.1:443");
39-
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_NTLSv1_1);
40-
curl_easy_setopt(curl, CURLOPT_SSL_CIPHER_LIST, "ECC-SM2-SM4-CBC-SM3");
36+
curl = curl_easy_init();
37+
if(curl) {
38+
curl_easy_setopt(curl, CURLOPT_URL, "https://127.0.0.1:443");
39+
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_NTLSv1_1);
40+
curl_easy_setopt(curl, CURLOPT_SSL_CIPHER_LIST, "ECC-SM2-SM4-CBC-SM3");
4141

42-
/* optional */
43-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
44-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
42+
/* optional */
43+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
44+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
4545

46-
res = curl_easy_perform(curl);
46+
res = curl_easy_perform(curl);
4747

48-
if(res != CURLE_OK)
49-
fprintf(stderr, "curl_easy_perform() failed: %s\n",
50-
curl_easy_strerror(res));
48+
if(res != CURLE_OK)
49+
fprintf(stderr, "curl_easy_perform() failed: %s\n",
50+
curl_easy_strerror(res));
5151

52-
curl_easy_cleanup(curl);
53-
}
52+
curl_easy_cleanup(curl);
53+
}
5454

55-
return 0;
55+
return 0;
5656
}
57-
// gcc https-tlcp.c -o https-tlcp -I/usr/local/curl/include -lcurl -L/usr/local/curl/lib -Wl,-rpath=/usr/local/curl/lib
57+
/*
58+
gcc https-tlcp.c -o https-tlcp -I/usr/local/curl/include -lcurl \
59+
-L/usr/local/curl/lib -Wl,-rpath=/usr/local/curl/lib
60+
*/

0 commit comments

Comments
 (0)