@@ -18,24 +18,54 @@ use std::str;
18
18
use std:: sync:: Mutex ;
19
19
use std:: sync:: Once ;
20
20
21
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
21
+ #[ cfg( not( any(
22
+ target_os = "ios" ,
23
+ target_os = "watchos" ,
24
+ target_os = "tvos" ,
25
+ target_os = "visionos"
26
+ ) ) ) ]
22
27
use self :: security_framework:: os:: macos:: certificate:: { PropertyType , SecCertificateExt } ;
23
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
28
+ #[ cfg( not( any(
29
+ target_os = "ios" ,
30
+ target_os = "watchos" ,
31
+ target_os = "tvos" ,
32
+ target_os = "visionos"
33
+ ) ) ) ]
24
34
use self :: security_framework:: os:: macos:: certificate_oids:: CertificateOid ;
25
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
35
+ #[ cfg( not( any(
36
+ target_os = "ios" ,
37
+ target_os = "watchos" ,
38
+ target_os = "tvos" ,
39
+ target_os = "visionos"
40
+ ) ) ) ]
26
41
use self :: security_framework:: os:: macos:: identity:: SecIdentityExt ;
27
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
42
+ #[ cfg( not( any(
43
+ target_os = "ios" ,
44
+ target_os = "watchos" ,
45
+ target_os = "tvos" ,
46
+ target_os = "visionos"
47
+ ) ) ) ]
28
48
use self :: security_framework:: os:: macos:: import_export:: {
29
49
ImportOptions , Pkcs12ImportOptionsExt , SecItems ,
30
50
} ;
31
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
51
+ #[ cfg( not( any(
52
+ target_os = "ios" ,
53
+ target_os = "watchos" ,
54
+ target_os = "tvos" ,
55
+ target_os = "visionos"
56
+ ) ) ) ]
32
57
use self :: security_framework:: os:: macos:: keychain:: { self , KeychainSettings , SecKeychain } ;
33
58
34
59
use { Protocol , TlsAcceptorBuilder , TlsConnectorBuilder } ;
35
60
36
61
static SET_AT_EXIT : Once = Once :: new ( ) ;
37
62
38
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
63
+ #[ cfg( not( any(
64
+ target_os = "ios" ,
65
+ target_os = "watchos" ,
66
+ target_os = "tvos" ,
67
+ target_os = "visionos"
68
+ ) ) ) ]
39
69
static TEMP_KEYCHAIN : Mutex < Option < ( SecKeychain , tempfile:: TempDir ) > > = Mutex :: new ( None ) ;
40
70
41
71
fn convert_protocol ( protocol : Protocol ) -> SslProtocol {
@@ -80,12 +110,22 @@ pub struct Identity {
80
110
}
81
111
82
112
impl Identity {
83
- #[ cfg( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ]
113
+ #[ cfg( any(
114
+ target_os = "ios" ,
115
+ target_os = "watchos" ,
116
+ target_os = "tvos" ,
117
+ target_os = "visionos"
118
+ ) ) ]
84
119
pub fn from_pkcs8 ( _: & [ u8 ] , _: & [ u8 ] ) -> Result < Identity , Error > {
85
120
panic ! ( "Not implemented on iOS" ) ;
86
121
}
87
122
88
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
123
+ #[ cfg( not( any(
124
+ target_os = "ios" ,
125
+ target_os = "watchos" ,
126
+ target_os = "tvos" ,
127
+ target_os = "visionos"
128
+ ) ) ) ]
89
129
pub fn from_pkcs8 ( pem : & [ u8 ] , key : & [ u8 ] ) -> Result < Identity , Error > {
90
130
if !key. starts_with ( b"-----BEGIN PRIVATE KEY-----" ) {
91
131
return Err ( Error ( base:: Error :: from ( errSecParam) ) ) ;
@@ -143,7 +183,12 @@ impl Identity {
143
183
} )
144
184
}
145
185
146
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
186
+ #[ cfg( not( any(
187
+ target_os = "ios" ,
188
+ target_os = "watchos" ,
189
+ target_os = "tvos" ,
190
+ target_os = "visionos"
191
+ ) ) ) ]
147
192
fn import_options ( buf : & [ u8 ] , pass : & str ) -> Result < Vec < ImportedIdentity > , Error > {
148
193
SET_AT_EXIT . call_once ( || {
149
194
extern "C" fn atexit ( ) {
@@ -176,7 +221,12 @@ impl Identity {
176
221
Ok ( imports)
177
222
}
178
223
179
- #[ cfg( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ]
224
+ #[ cfg( any(
225
+ target_os = "ios" ,
226
+ target_os = "watchos" ,
227
+ target_os = "tvos" ,
228
+ target_os = "visionos"
229
+ ) ) ]
180
230
fn import_options ( buf : & [ u8 ] , pass : & str ) -> Result < Vec < ImportedIdentity > , Error > {
181
231
let imports = Pkcs12ImportOptions :: new ( ) . passphrase ( pass) . import ( buf) ?;
182
232
Ok ( imports)
@@ -205,7 +255,12 @@ impl Certificate {
205
255
Ok ( Certificate ( cert) )
206
256
}
207
257
208
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
258
+ #[ cfg( not( any(
259
+ target_os = "ios" ,
260
+ target_os = "watchos" ,
261
+ target_os = "tvos" ,
262
+ target_os = "visionos"
263
+ ) ) ) ]
209
264
pub fn from_pem ( buf : & [ u8 ] ) -> Result < Certificate , Error > {
210
265
let mut items = SecItems :: default ( ) ;
211
266
ImportOptions :: new ( ) . items ( & mut items) . import ( buf) ?;
@@ -216,9 +271,14 @@ impl Certificate {
216
271
}
217
272
}
218
273
219
- #[ cfg( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ]
274
+ #[ cfg( any(
275
+ target_os = "ios" ,
276
+ target_os = "watchos" ,
277
+ target_os = "tvos" ,
278
+ target_os = "visionos"
279
+ ) ) ]
220
280
pub fn from_pem ( _: & [ u8 ] ) -> Result < Certificate , Error > {
221
- panic ! ( "Not implemented on iOS, tvOS or watchOS " ) ;
281
+ panic ! ( "Not implemented on iOS, tvOS, watchOS or visionOS " ) ;
222
282
}
223
283
224
284
pub fn to_der ( & self ) -> Result < Vec < u8 > , Error > {
@@ -475,12 +535,22 @@ impl<S: io::Read + io::Write> TlsStream<S> {
475
535
}
476
536
}
477
537
478
- #[ cfg( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ]
538
+ #[ cfg( any(
539
+ target_os = "ios" ,
540
+ target_os = "watchos" ,
541
+ target_os = "tvos" ,
542
+ target_os = "visionos"
543
+ ) ) ]
479
544
pub fn tls_server_end_point ( & self ) -> Result < Option < Vec < u8 > > , Error > {
480
545
Ok ( None )
481
546
}
482
547
483
- #[ cfg( not( any( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
548
+ #[ cfg( not( any(
549
+ target_os = "ios" ,
550
+ target_os = "watchos" ,
551
+ target_os = "tvos" ,
552
+ target_os = "visionos"
553
+ ) ) ) ]
484
554
pub fn tls_server_end_point ( & self ) -> Result < Option < Vec < u8 > > , Error > {
485
555
let cert = match self . cert {
486
556
Some ( ref cert) => cert. clone ( ) ,
0 commit comments