File tree 6 files changed +105
-1
lines changed
6 files changed +105
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ spnego = ["curl-sys/spnego"]
47
47
rustls = [" curl-sys/rustls" ]
48
48
static-curl = [" curl-sys/static-curl" ]
49
49
static-ssl = [" curl-sys/static-ssl" ]
50
+ windows-static-ssl = [" static-curl" , " curl-sys/windows-static-ssl" ]
50
51
force-system-lib-on-osx = [' curl-sys/force-system-lib-on-osx' ]
51
52
protocol-ftp = [" curl-sys/protocol-ftp" ]
52
53
zlib-ng-compat = [" curl-sys/zlib-ng-compat" , " static-curl" ]
@@ -72,6 +73,11 @@ name = "ssl_cert_blob"
72
73
path = " examples/ssl_cert_blob.rs"
73
74
required-features = [" ssl" ]
74
75
76
+ [[example ]]
77
+ name = " ssl_client_auth"
78
+ path = " examples/ssl_client_auth.rs"
79
+ required-features = []
80
+
75
81
[[example ]]
76
82
name = " aws_sigv4"
77
83
path = " examples/aws_sigv4.rs"
Original file line number Diff line number Diff line change @@ -133,6 +133,16 @@ with various Cargo features:
133
133
- ` upkeep_7_62_0 ` : Enable curl_easy_upkeep() support, introduced in curl 7.62.0. Disabled by default.
134
134
- ` poll_7_68_0 ` : Enable curl_multi_poll()/curl_multi_wakeup() support, requires curl 7.68.0 or later. Disabled by default.
135
135
- ` ntlm ` : Enable NTLM support in curl. Disabled by default.
136
+ - ` windows-static-ssl ` : Enable Openssl support on Windows via the static build provided by vcpkg. Incompatible with ` ssl ` (use ` --no-default-features ` ). Disabled by default.
137
+
138
+ Note that to install openssl on windows via vcpkg the following commands needs to be ran:
139
+ ``` shell
140
+ git clone https://github.com/microsoft/vcpkg
141
+ cd vcpkg
142
+ ./bootstrap-vcpkg.bat -disableMetrics
143
+ ./vcpkg.exe integrate install
144
+ ./vcpkg.exe install openssl:x64-windows-static-md
145
+ ```
136
146
137
147
## Version Support
138
148
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ http2 = ["libnghttp2-sys"]
49
49
mesalink = []
50
50
rustls = [" rustls-ffi" ]
51
51
static-curl = []
52
+ windows-static-ssl = []
52
53
static-ssl = [" openssl-sys/vendored" ]
53
54
spnego = []
54
55
force-system-lib-on-osx = []
Original file line number Diff line number Diff line change @@ -274,6 +274,26 @@ fn main() {
274
274
cfg. define ( "USE_RUSTLS" , None )
275
275
. file ( "curl/lib/vtls/rustls.c" )
276
276
. include ( env:: var_os ( "DEP_RUSTLS_FFI_INCLUDE" ) . unwrap ( ) ) ;
277
+ } else if cfg ! ( feature = "windows-static-ssl" ) {
278
+ if windows {
279
+ cfg. define ( "USE_OPENSSL" , None )
280
+ . file ( "curl/lib/vtls/openssl.c" ) ;
281
+ // We need both openssl and zlib
282
+ // Those can be installed with
283
+ // ```shell
284
+ // git clone https://github.com/microsoft/vcpkg
285
+ // cd vcpkg
286
+ // ./bootstrap-vcpkg.bat -disableMetrics
287
+ // ./vcpkg.exe integrate install
288
+ // ./vcpkg.exe install openssl:x64-windows-static-md
289
+ // ```
290
+ #[ cfg( target_env = "msvc" ) ]
291
+ vcpkg:: Config :: new ( ) . find_package ( "openssl" ) . ok ( ) ;
292
+ #[ cfg( target_env = "msvc" ) ]
293
+ vcpkg:: Config :: new ( ) . find_package ( "zlib" ) . ok ( ) ;
294
+ } else {
295
+ panic ! ( "Not available on non windows platform" )
296
+ }
277
297
} else if cfg ! ( feature = "ssl" ) {
278
298
if windows {
279
299
// For windows, spnego feature is auto on in case ssl feature is on.
Original file line number Diff line number Diff line change @@ -16,11 +16,21 @@ fn read_file(path: impl AsRef<Path>) -> Result<Vec<u8>> {
16
16
fn main ( ) -> Result < ( ) > {
17
17
let argv = env:: args ( ) . collect :: < Vec < _ > > ( ) ;
18
18
if argv. len ( ) < 4 {
19
- bail ! ( "usage: ssl_cert_blob URL CERT KEY" ) ;
19
+ bail ! ( "usage: ssl_cert_blob URL CERT KEY CAINFO? PASSWORD? " ) ;
20
20
}
21
21
let url = & argv[ 1 ] ;
22
22
let cert_path = & argv[ 2 ] ;
23
23
let key_path = & argv[ 3 ] ;
24
+ let cainfo = if argv. len ( ) >= 5 {
25
+ Some ( & argv[ 4 ] )
26
+ } else {
27
+ None
28
+ } ;
29
+ let password = if argv. len ( ) >= 6 {
30
+ Some ( & argv[ 5 ] )
31
+ } else {
32
+ None
33
+ } ;
24
34
25
35
let mut handle = Easy :: new ( ) ;
26
36
@@ -33,9 +43,20 @@ fn main() -> Result<()> {
33
43
34
44
let cert_blob = read_file ( cert_path) ?;
35
45
let key_blob = read_file ( key_path) ?;
46
+ let ca_blob = if let Some ( cainfo) = cainfo {
47
+ Some ( read_file ( cainfo) ?)
48
+ } else {
49
+ None
50
+ } ;
36
51
37
52
handle. ssl_cert_blob ( & cert_blob) ?;
38
53
handle. ssl_key_blob ( & key_blob) ?;
54
+ if let Some ( password) = password {
55
+ handle. key_password ( password) ?;
56
+ }
57
+ if let Some ( ca_blob) = ca_blob {
58
+ handle. ssl_cainfo_blob ( & ca_blob) ?;
59
+ }
39
60
40
61
handle. perform ( ) ?;
41
62
Ok ( ( ) )
Original file line number Diff line number Diff line change
1
+ use std:: env;
2
+ use std:: io:: { stdout, Write } ;
3
+
4
+ use anyhow:: { bail, Result } ;
5
+ use curl:: easy:: Easy ;
6
+
7
+ fn main ( ) -> Result < ( ) > {
8
+ let argv = env:: args ( ) . collect :: < Vec < _ > > ( ) ;
9
+ if argv. len ( ) < 4 {
10
+ bail ! ( "usage: ssl_client_auth URL CERT KEY CAINFO? PASSWORD?" ) ;
11
+ }
12
+ let url = & argv[ 1 ] ;
13
+ let cert_path = & argv[ 2 ] ;
14
+ let key_path = & argv[ 3 ] ;
15
+ let cainfo = if argv. len ( ) >= 5 {
16
+ Some ( & argv[ 4 ] )
17
+ } else {
18
+ None
19
+ } ;
20
+ let password = if argv. len ( ) >= 6 {
21
+ Some ( & argv[ 5 ] )
22
+ } else {
23
+ None
24
+ } ;
25
+
26
+ let mut handle = Easy :: new ( ) ;
27
+
28
+ handle. url ( url) ?;
29
+ handle. verbose ( true ) ?;
30
+ handle. write_function ( |data| {
31
+ stdout ( ) . write_all ( data) . unwrap ( ) ;
32
+ Ok ( data. len ( ) )
33
+ } ) ?;
34
+
35
+ handle. ssl_cert ( & cert_path) ?;
36
+ handle. ssl_key ( & key_path) ?;
37
+ if let Some ( password) = password {
38
+ handle. key_password ( password) ?;
39
+ }
40
+ if let Some ( cainfo) = cainfo {
41
+ handle. cainfo ( cainfo) ?;
42
+ }
43
+
44
+ handle. perform ( ) ?;
45
+ Ok ( ( ) )
46
+ }
You can’t perform that action at this time.
0 commit comments