@@ -18,24 +18,54 @@ use std::str;
1818use  std:: sync:: Mutex ; 
1919use  std:: sync:: Once ; 
2020
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+ ) ) ) ] 
2227use  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+ ) ) ) ] 
2434use  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+ ) ) ) ] 
2641use  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+ ) ) ) ] 
2848use  self :: security_framework:: os:: macos:: import_export:: { 
2949    ImportOptions ,  Pkcs12ImportOptionsExt ,  SecItems , 
3050} ; 
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+ ) ) ) ] 
3257use  self :: security_framework:: os:: macos:: keychain:: { self ,  KeychainSettings ,  SecKeychain } ; 
3358
3459use  { Protocol ,  TlsAcceptorBuilder ,  TlsConnectorBuilder } ; 
3560
3661static  SET_AT_EXIT :  Once  = Once :: new ( ) ; 
3762
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+ ) ) ) ] 
3969static  TEMP_KEYCHAIN :  Mutex < Option < ( SecKeychain ,  tempfile:: TempDir ) > >  = Mutex :: new ( None ) ; 
4070
4171fn  convert_protocol ( protocol :  Protocol )  -> SslProtocol  { 
@@ -80,12 +110,22 @@ pub struct Identity {
80110} 
81111
82112impl  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+     ) ) ]  
84119    pub  fn  from_pkcs8 ( _:  & [ u8 ] ,  _:  & [ u8 ] )  -> Result < Identity ,  Error >  { 
85120        panic ! ( "Not implemented on iOS" ) ; 
86121    } 
87122
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+     ) ) ) ]  
89129    pub  fn  from_pkcs8 ( pem :  & [ u8 ] ,  key :  & [ u8 ] )  -> Result < Identity ,  Error >  { 
90130        if  !key. starts_with ( b"-----BEGIN PRIVATE KEY-----" )  { 
91131            return  Err ( Error ( base:: Error :: from ( errSecParam) ) ) ; 
@@ -143,7 +183,12 @@ impl Identity {
143183        } ) 
144184    } 
145185
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+     ) ) ) ]  
147192    fn  import_options ( buf :  & [ u8 ] ,  pass :  & str )  -> Result < Vec < ImportedIdentity > ,  Error >  { 
148193        SET_AT_EXIT . call_once ( || { 
149194            extern  "C"  fn  atexit ( )  { 
@@ -176,7 +221,12 @@ impl Identity {
176221        Ok ( imports) 
177222    } 
178223
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+     ) ) ]  
180230    fn  import_options ( buf :  & [ u8 ] ,  pass :  & str )  -> Result < Vec < ImportedIdentity > ,  Error >  { 
181231        let  imports = Pkcs12ImportOptions :: new ( ) . passphrase ( pass) . import ( buf) ?; 
182232        Ok ( imports) 
@@ -205,7 +255,12 @@ impl Certificate {
205255        Ok ( Certificate ( cert) ) 
206256    } 
207257
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+     ) ) ) ]  
209264    pub  fn  from_pem ( buf :  & [ u8 ] )  -> Result < Certificate ,  Error >  { 
210265        let  mut  items = SecItems :: default ( ) ; 
211266        ImportOptions :: new ( ) . items ( & mut  items) . import ( buf) ?; 
@@ -216,9 +271,14 @@ impl Certificate {
216271        } 
217272    } 
218273
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+     ) ) ]  
220280    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 " ) ; 
222282    } 
223283
224284    pub  fn  to_der ( & self )  -> Result < Vec < u8 > ,  Error >  { 
@@ -475,12 +535,22 @@ impl<S: io::Read + io::Write> TlsStream<S> {
475535        } 
476536    } 
477537
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+     ) ) ]  
479544    pub  fn  tls_server_end_point ( & self )  -> Result < Option < Vec < u8 > > ,  Error >  { 
480545        Ok ( None ) 
481546    } 
482547
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+     ) ) ) ]  
484554    pub  fn  tls_server_end_point ( & self )  -> Result < Option < Vec < u8 > > ,  Error >  { 
485555        let  cert = match  self . cert  { 
486556            Some ( ref  cert)  => cert. clone ( ) , 
0 commit comments