@@ -20,24 +20,24 @@ use std::str;
2020use std:: sync:: Mutex ;
2121use std:: sync:: Once ;
2222
23- #[ cfg( not( target_os = "ios" ) ) ]
23+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
2424use self :: security_framework:: os:: macos:: certificate:: { PropertyType , SecCertificateExt } ;
25- #[ cfg( not( target_os = "ios" ) ) ]
25+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
2626use self :: security_framework:: os:: macos:: certificate_oids:: CertificateOid ;
27- #[ cfg( not( target_os = "ios" ) ) ]
27+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
2828use self :: security_framework:: os:: macos:: identity:: SecIdentityExt ;
29- #[ cfg( not( target_os = "ios" ) ) ]
29+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
3030use self :: security_framework:: os:: macos:: import_export:: {
3131 ImportOptions , Pkcs12ImportOptionsExt , SecItems ,
3232} ;
33- #[ cfg( not( target_os = "ios" ) ) ]
33+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
3434use self :: security_framework:: os:: macos:: keychain:: { self , KeychainSettings , SecKeychain } ;
3535
3636use { Protocol , TlsAcceptorBuilder , TlsConnectorBuilder } ;
3737
3838static SET_AT_EXIT : Once = Once :: new ( ) ;
3939
40- #[ cfg( not( target_os = "ios" ) ) ]
40+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
4141static TEMP_KEYCHAIN : Mutex < Option < ( SecKeychain , TempDir ) > > = Mutex :: new ( None ) ;
4242
4343fn convert_protocol ( protocol : Protocol ) -> SslProtocol {
@@ -82,12 +82,12 @@ pub struct Identity {
8282}
8383
8484impl Identity {
85- #[ cfg( target_os = "ios" ) ]
85+ #[ cfg( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ]
8686 pub fn from_pkcs8 ( _: & [ u8 ] , _: & [ u8 ] ) -> Result < Identity , Error > {
8787 panic ! ( "Not implemented on iOS" ) ;
8888 }
8989
90- #[ cfg( not( target_os = "ios" ) ) ]
90+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
9191 pub fn from_pkcs8 ( pem : & [ u8 ] , key : & [ u8 ] ) -> Result < Identity , Error > {
9292 if !key. starts_with ( b"-----BEGIN PRIVATE KEY-----" ) {
9393 return Err ( Error ( base:: Error :: from ( errSecParam) ) ) ;
@@ -145,7 +145,7 @@ impl Identity {
145145 } )
146146 }
147147
148- #[ cfg( not( target_os = "ios" ) ) ]
148+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
149149 fn import_options ( buf : & [ u8 ] , pass : & str ) -> Result < Vec < ImportedIdentity > , Error > {
150150 SET_AT_EXIT . call_once ( || {
151151 extern "C" fn atexit ( ) {
@@ -177,7 +177,7 @@ impl Identity {
177177 Ok ( imports)
178178 }
179179
180- #[ cfg( target_os = "ios" ) ]
180+ #[ cfg( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ]
181181 fn import_options ( buf : & [ u8 ] , pass : & str ) -> Result < Vec < ImportedIdentity > , Error > {
182182 let imports = Pkcs12ImportOptions :: new ( ) . passphrase ( pass) . import ( buf) ?;
183183 Ok ( imports)
@@ -206,7 +206,7 @@ impl Certificate {
206206 Ok ( Certificate ( cert) )
207207 }
208208
209- #[ cfg( not( target_os = "ios" ) ) ]
209+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
210210 pub fn from_pem ( buf : & [ u8 ] ) -> Result < Certificate , Error > {
211211 let mut items = SecItems :: default ( ) ;
212212 ImportOptions :: new ( ) . items ( & mut items) . import ( buf) ?;
@@ -217,9 +217,9 @@ impl Certificate {
217217 }
218218 }
219219
220- #[ cfg( target_os = "ios" ) ]
220+ #[ cfg( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ]
221221 pub fn from_pem ( _: & [ u8 ] ) -> Result < Certificate , Error > {
222- panic ! ( "Not implemented on iOS" ) ;
222+ panic ! ( "Not implemented on iOS, tvOS or watchOS " ) ;
223223 }
224224
225225 pub fn to_der ( & self ) -> Result < Vec < u8 > , Error > {
@@ -476,12 +476,12 @@ impl<S: io::Read + io::Write> TlsStream<S> {
476476 }
477477 }
478478
479- #[ cfg( target_os = "ios" ) ]
479+ #[ cfg( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ]
480480 pub fn tls_server_end_point ( & self ) -> Result < Option < Vec < u8 > > , Error > {
481481 Ok ( None )
482482 }
483483
484- #[ cfg( not( target_os = "ios" ) ) ]
484+ #[ cfg( not( any ( target_os = "ios" , target_os = "watchos" , target_os = "tvos" ) ) ) ]
485485 pub fn tls_server_end_point ( & self ) -> Result < Option < Vec < u8 > > , Error > {
486486 let cert = match self . cert {
487487 Some ( ref cert) => cert. clone ( ) ,
0 commit comments