Skip to content

Commit f804521

Browse files
committed
Added visionos target support
1 parent 0b69ce6 commit f804521

File tree

3 files changed

+91
-19
lines changed

3 files changed

+91
-19
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ rustdoc-args = ["--cfg", "docsrs"]
1616
vendored = ["openssl/vendored"]
1717
alpn = ["security-framework/alpn"]
1818

19-
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))'.dependencies]
19+
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos", target_os = "visionos"))'.dependencies]
2020
security-framework = "2.0.0"
2121
security-framework-sys = "2.0.0"
2222
libc = "0.2"
@@ -25,7 +25,7 @@ tempfile = "3.1.0"
2525
[target.'cfg(target_os = "windows")'.dependencies]
2626
schannel = "0.1.17"
2727

28-
[target.'cfg(not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos")))'.dependencies]
28+
[target.'cfg(not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos", target_os = "visionos")))'.dependencies]
2929
log = "0.4.5"
3030
openssl = "0.10.29"
3131
openssl-sys = "0.9.55"

src/imp/security_framework.rs

+85-15
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,54 @@ use std::str;
2020
use std::sync::Mutex;
2121
use std::sync::Once;
2222

23-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
23+
#[cfg(not(any(
24+
target_os = "ios",
25+
target_os = "watchos",
26+
target_os = "tvos",
27+
target_os = "visionos"
28+
)))]
2429
use self::security_framework::os::macos::certificate::{PropertyType, SecCertificateExt};
25-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
30+
#[cfg(not(any(
31+
target_os = "ios",
32+
target_os = "watchos",
33+
target_os = "tvos",
34+
target_os = "visionos"
35+
)))]
2636
use self::security_framework::os::macos::certificate_oids::CertificateOid;
27-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
37+
#[cfg(not(any(
38+
target_os = "ios",
39+
target_os = "watchos",
40+
target_os = "tvos",
41+
target_os = "visionos"
42+
)))]
2843
use self::security_framework::os::macos::identity::SecIdentityExt;
29-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
44+
#[cfg(not(any(
45+
target_os = "ios",
46+
target_os = "watchos",
47+
target_os = "tvos",
48+
target_os = "visionos"
49+
)))]
3050
use self::security_framework::os::macos::import_export::{
3151
ImportOptions, Pkcs12ImportOptionsExt, SecItems,
3252
};
33-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
53+
#[cfg(not(any(
54+
target_os = "ios",
55+
target_os = "watchos",
56+
target_os = "tvos",
57+
target_os = "visionos"
58+
)))]
3459
use self::security_framework::os::macos::keychain::{self, KeychainSettings, SecKeychain};
3560

3661
use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
3762

3863
static SET_AT_EXIT: Once = Once::new();
3964

40-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
65+
#[cfg(not(any(
66+
target_os = "ios",
67+
target_os = "watchos",
68+
target_os = "tvos",
69+
target_os = "visionos"
70+
)))]
4171
static TEMP_KEYCHAIN: Mutex<Option<(SecKeychain, TempDir)>> = Mutex::new(None);
4272

4373
fn convert_protocol(protocol: Protocol) -> SslProtocol {
@@ -82,12 +112,22 @@ pub struct Identity {
82112
}
83113

84114
impl Identity {
85-
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
115+
#[cfg(any(
116+
target_os = "ios",
117+
target_os = "watchos",
118+
target_os = "tvos",
119+
target_os = "visionos"
120+
))]
86121
pub fn from_pkcs8(_: &[u8], _: &[u8]) -> Result<Identity, Error> {
87122
panic!("Not implemented on iOS");
88123
}
89124

90-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
125+
#[cfg(not(any(
126+
target_os = "ios",
127+
target_os = "watchos",
128+
target_os = "tvos",
129+
target_os = "visionos"
130+
)))]
91131
pub fn from_pkcs8(pem: &[u8], key: &[u8]) -> Result<Identity, Error> {
92132
if !key.starts_with(b"-----BEGIN PRIVATE KEY-----") {
93133
return Err(Error(base::Error::from(errSecParam)));
@@ -145,7 +185,12 @@ impl Identity {
145185
})
146186
}
147187

148-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
188+
#[cfg(not(any(
189+
target_os = "ios",
190+
target_os = "watchos",
191+
target_os = "tvos",
192+
target_os = "visionos"
193+
)))]
149194
fn import_options(buf: &[u8], pass: &str) -> Result<Vec<ImportedIdentity>, Error> {
150195
SET_AT_EXIT.call_once(|| {
151196
extern "C" fn atexit() {
@@ -177,7 +222,12 @@ impl Identity {
177222
Ok(imports)
178223
}
179224

180-
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
225+
#[cfg(any(
226+
target_os = "ios",
227+
target_os = "watchos",
228+
target_os = "tvos",
229+
target_os = "visionos"
230+
))]
181231
fn import_options(buf: &[u8], pass: &str) -> Result<Vec<ImportedIdentity>, Error> {
182232
let imports = Pkcs12ImportOptions::new().passphrase(pass).import(buf)?;
183233
Ok(imports)
@@ -206,7 +256,12 @@ impl Certificate {
206256
Ok(Certificate(cert))
207257
}
208258

209-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
259+
#[cfg(not(any(
260+
target_os = "ios",
261+
target_os = "watchos",
262+
target_os = "tvos",
263+
target_os = "visionos"
264+
)))]
210265
pub fn from_pem(buf: &[u8]) -> Result<Certificate, Error> {
211266
let mut items = SecItems::default();
212267
ImportOptions::new().items(&mut items).import(buf)?;
@@ -217,9 +272,14 @@ impl Certificate {
217272
}
218273
}
219274

220-
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
275+
#[cfg(any(
276+
target_os = "ios",
277+
target_os = "watchos",
278+
target_os = "tvos",
279+
target_os = "visionos"
280+
))]
221281
pub fn from_pem(_: &[u8]) -> Result<Certificate, Error> {
222-
panic!("Not implemented on iOS, tvOS or watchOS");
282+
panic!("Not implemented on iOS, tvOS, watchOS or visionOS");
223283
}
224284

225285
pub fn to_der(&self) -> Result<Vec<u8>, Error> {
@@ -476,12 +536,22 @@ impl<S: io::Read + io::Write> TlsStream<S> {
476536
}
477537
}
478538

479-
#[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))]
539+
#[cfg(any(
540+
target_os = "ios",
541+
target_os = "watchos",
542+
target_os = "tvos",
543+
target_os = "visionos"
544+
))]
480545
pub fn tls_server_end_point(&self) -> Result<Option<Vec<u8>>, Error> {
481546
Ok(None)
482547
}
483548

484-
#[cfg(not(any(target_os = "ios", target_os = "watchos", target_os = "tvos")))]
549+
#[cfg(not(any(
550+
target_os = "ios",
551+
target_os = "watchos",
552+
target_os = "tvos",
553+
target_os = "visionos"
554+
)))]
485555
pub fn tls_server_end_point(&self) -> Result<Option<Vec<u8>>, Error> {
486556
let cert = match self.cert {
487557
Some(ref cert) => cert.clone(),

src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ extern crate log;
117117
target_os = "macos",
118118
target_os = "ios",
119119
target_os = "watchos",
120-
target_os = "tvos"
120+
target_os = "tvos",
121+
target_os = "visionos"
121122
))]
122123
#[path = "imp/security_framework.rs"]
123124
mod imp;
@@ -129,7 +130,8 @@ mod imp;
129130
target_os = "windows",
130131
target_os = "ios",
131132
target_os = "watchos",
132-
target_os = "tvos"
133+
target_os = "tvos",
134+
target_os = "visionos"
133135
)))]
134136
#[path = "imp/openssl.rs"]
135137
mod imp;

0 commit comments

Comments
 (0)