Skip to content

Commit 3c89d42

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

File tree

8 files changed

+1025
-879
lines changed

8 files changed

+1025
-879
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

+16-15
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
- '*'
@@ -34,20 +34,20 @@ jobs:
3434
needs: [new_release]
3535
strategy:
3636
matrix:
37-
builder: [macos-latest, ubuntu-20.04]
37+
builder: [ubuntu-20.04, macos-latest, macos-13]
3838
name: "build-${{ matrix.builder }}"
3939
steps:
40-
- run: |
41-
brew install libtool autoconf automake pkg-config
42-
mv /usr/local/include/openssl /usr/local/include/openssl.bak
43-
if: ${{ matrix.builder == 'macos-latest' }}
40+
- run: brew install libtool autoconf automake pkg-config
41+
if: ${{ matrix.builder == 'macos-latest' || matrix.builder == 'macos-13' }}
42+
- run: mv /usr/local/include/openssl /usr/local/include/openssl.bak
43+
if: ${{ matrix.builder == 'macos-13' }}
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,15 +62,14 @@ 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:
6968
GITHUB_TOKEN: ${{ github.token }}
7069
with:
7170
upload_url: ${{ needs.new_release.outputs.upload_url }}
7271
asset_path: ./curl/src/curl
73-
asset_name: curl-${{ runner.os }}
72+
asset_name: curl-${{ runner.os }}-${{ runner.arch }}
7473
asset_content_type: application/octet-stream
7574

7675
build_windows:
@@ -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
@@ -116,16 +115,18 @@ jobs:
116115
working-directory: ./curl
117116
shell: powershell
118117
run: |
119-
git apply tongsuo.diff
118+
git apply --reject tongsuo.patc
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 MACHINE=x64 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:
126127
GITHUB_TOKEN: ${{ github.token }}
127128
with:
128129
upload_url: ${{ needs.new_release.outputs.upload_url }}
129130
asset_path: .\curl\builds\libcurl-vc-x64-release-static-ssl-static-ipv6-sspi\bin\curl.exe
130-
asset_name: curl-${{ runner.os }}.exe
131+
asset_name: curl-${{ runner.os }}-${{ runner.arch }}.exe
131132
asset_content_type: application/octet-stream

.github/workflows/reuse.yml

-33
This file was deleted.

.github/workflows/tongsuo.yml

+73-18
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,91 @@
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: [ubuntu-20.04, macos-latest, macos-13]
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: brew install libtool autoconf automake pkg-config
18+
if: ${{ matrix.builder == 'macos-latest' || matrix.builder == 'macos-13' }}
19+
- run: mv /usr/local/include/openssl /usr/local/include/openssl.bak
20+
if: ${{ matrix.builder == 'macos-13' }}
21+
- name: build Tongsuo
2222
run: |
23-
./config --banner=Configured --prefix=${GITHUB_WORKSPACE}/install enable-ntls
23+
VERSION=8.4.0
24+
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${VERSION}.tar.gz"
25+
tar zxf "${VERSION}.tar.gz"
26+
pushd "Tongsuo-${VERSION}"
27+
./config --prefix=${GITHUB_WORKSPACE}/tongsuo no-shared enable-ntls enable-ssl-trace --release
2428
make -s -j4
25-
make install
26-
- uses: actions/checkout@v3
29+
make install_sw
30+
popd
31+
- uses: actions/checkout@v2
2732
with:
2833
path: curl
29-
34+
fetch-depth: 0
3035
- name: build curl
3136
working-directory: ./curl
3237
run: |
3338
git apply tongsuo.patch
3439
autoreconf -fi
35-
LDFLAGS=-Wl,-rpath=${GITHUB_WORKSPACE}/install/lib64/ ./configure --enable-warnings --enable-werror --with-openssl=${GITHUB_WORKSPACE}/install
36-
make V=1
40+
./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
41+
make -s -j4
3742
make V=1 examples
3843
make V=1 -C tests
3944
make V=1 test-ci
45+
./src/curl --help tls | grep tlcp
46+
47+
build_windows:
48+
runs-on: windows-latest
49+
steps:
50+
- run: choco install -y winrar
51+
- uses: ilammy/msvc-dev-cmd@v1
52+
with:
53+
arch: win64
54+
- uses: ilammy/setup-nasm@v1
55+
with:
56+
platform: win64
57+
- uses: shogo82148/actions-setup-perl@v1
58+
- name: Export env
59+
shell: bash
60+
run: |
61+
VERSION=8.4.0
62+
echo "TONGSUO_VERSION=${VERSION}" >> $GITHUB_ENV
63+
echo "TONGSUO_HOME=${GITHUB_WORKSPACE}\tongsuo${VERSION}" >> $GITHUB_ENV
64+
- name: Download Tongsuo source
65+
run: |
66+
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${env:TONGSUO_VERSION}.tar.gz" -OutFile "${env:TONGSUO_VERSION}.tar.gz"
67+
shell: powershell
68+
- run: '"C:\Program Files\WinRAR\WinRAR.exe" -INUL x %TONGSUO_VERSION%.tar.gz'
69+
shell: cmd
70+
- name: Build Tongsuo
71+
shell: cmd
72+
run: |
73+
pushd "Tongsuo-%TONGSUO_VERSION%"
74+
mkdir _build
75+
pushd _build
76+
perl ..\Configure no-makedepend no-shared enable-ntls enable-ssl-trace VC-WIN64A --prefix=%TONGSUO_HOME% --release
77+
nmake /S
78+
nmake install_sw
79+
popd
80+
popd
81+
- uses: actions/checkout@v2
82+
with:
83+
path: curl
84+
fetch-depth: 0
85+
- name: build curl
86+
working-directory: ./curl
87+
shell: powershell
88+
run: |
89+
git apply --reject tongsuo.patch
90+
./buildconf.bat
91+
cd winbuild
92+
nmake /f Makefile.vc MACHINE=x64 mode=static WITH_SSL=static SSL_PATH=${env:TONGSUO_HOME} RTLIBCFG=static ENABLE_NTLS=yes
93+
cd ..
94+
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)