Skip to content

Commit 596a0eb

Browse files
committed
Upgrade to Edition 2021
1 parent 56dc8cb commit 596a0eb

File tree

4 files changed

+39
-44
lines changed

4 files changed

+39
-44
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ description = "A wrapper over a platform's native TLS implementation"
77
repository = "https://github.com/sfackler/rust-native-tls"
88
readme = "README.md"
99
rust-version = "1.80.0"
10+
edition = "2021"
1011

1112
[package.metadata.docs.rs]
1213
features = ["alpn"]

src/imp/openssl.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
extern crate openssl;
2-
extern crate openssl_probe;
3-
4-
use self::openssl::error::ErrorStack;
5-
use self::openssl::hash::MessageDigest;
6-
use self::openssl::nid::Nid;
7-
use self::openssl::pkcs12::Pkcs12;
8-
use self::openssl::pkey::{PKey, Private};
9-
use self::openssl::ssl::{
1+
use openssl::error::ErrorStack;
2+
use openssl::hash::MessageDigest;
3+
use openssl::nid::Nid;
4+
use openssl::pkcs12::Pkcs12;
5+
use openssl::pkey::{PKey, Private};
6+
use openssl::ssl::{
107
self, MidHandshakeSslStream, SslAcceptor, SslConnector, SslContextBuilder, SslMethod,
118
SslVerifyMode,
129
};
13-
use self::openssl::x509::{store::X509StoreBuilder, X509VerifyResult, X509};
14-
use self::openssl_probe::ProbeResult;
10+
use openssl::x509::{store::X509StoreBuilder, X509VerifyResult, X509};
11+
use openssl_probe::ProbeResult;
1512
use std::error;
1613
use std::fmt;
1714
use std::io;
1815
use std::sync::LazyLock;
1916

20-
use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
17+
use crate::{Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
2118

2219
static PROBE_RESULT: LazyLock<ProbeResult> = LazyLock::new(openssl_probe::probe);
2320

@@ -27,7 +24,7 @@ fn supported_protocols(
2724
max: Option<Protocol>,
2825
ctx: &mut SslContextBuilder,
2926
) -> Result<(), ErrorStack> {
30-
use self::openssl::ssl::SslVersion;
27+
use openssl::ssl::SslVersion;
3128

3229
fn cvt(p: Protocol) -> SslVersion {
3330
match p {
@@ -50,7 +47,7 @@ fn supported_protocols(
5047
max: Option<Protocol>,
5148
ctx: &mut SslContextBuilder,
5249
) -> Result<(), ErrorStack> {
53-
use self::openssl::ssl::SslOptions;
50+
use openssl::ssl::SslOptions;
5451

5552
let no_ssl_mask = SslOptions::NO_SSLV2
5653
| SslOptions::NO_SSLV3

src/imp/schannel.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
extern crate schannel;
2-
3-
use self::schannel::cert_context::{CertContext, HashAlgorithm, KeySpec};
4-
use self::schannel::cert_store::{CertAdd, CertStore, Memory, PfxImportOptions};
5-
use self::schannel::crypt_prov::{AcquireOptions, ProviderType};
6-
use self::schannel::schannel_cred::{Direction, Protocol, SchannelCred};
7-
use self::schannel::tls_stream;
1+
use schannel::cert_context::{CertContext, HashAlgorithm, KeySpec};
2+
use schannel::cert_store::{CertAdd, CertStore, Memory, PfxImportOptions};
3+
use schannel::crypt_prov::{AcquireOptions, ProviderType};
4+
use schannel::schannel_cred::{Direction, Protocol, SchannelCred};
5+
use schannel::tls_stream;
86
use std::error;
97
use std::fmt;
108
use std::io;
119
use std::str;
1210

13-
use {TlsAcceptorBuilder, TlsConnectorBuilder};
11+
use crate::{TlsAcceptorBuilder, TlsConnectorBuilder};
1412

1513
const SEC_E_NO_CREDENTIALS: u32 = 0x8009030E;
1614

@@ -21,7 +19,10 @@ static PROTOCOLS: &'static [Protocol] = &[
2119
Protocol::Tls12,
2220
];
2321

24-
fn convert_protocols(min: Option<::Protocol>, max: Option<::Protocol>) -> &'static [Protocol] {
22+
fn convert_protocols(
23+
min: Option<crate::Protocol>,
24+
max: Option<crate::Protocol>,
25+
) -> &'static [Protocol] {
2526
let mut protocols = PROTOCOLS;
2627
if let Some(p) = max.and_then(|max| protocols.get(..=max as usize)) {
2728
protocols = p;
@@ -236,8 +237,8 @@ impl<S> From<io::Error> for HandshakeError<S> {
236237
pub struct TlsConnector {
237238
cert: Option<CertContext>,
238239
roots: CertStore,
239-
min_protocol: Option<::Protocol>,
240-
max_protocol: Option<::Protocol>,
240+
min_protocol: Option<crate::Protocol>,
241+
max_protocol: Option<crate::Protocol>,
241242
use_sni: bool,
242243
accept_invalid_hostnames: bool,
243244
accept_invalid_certs: bool,
@@ -327,8 +328,8 @@ impl TlsConnector {
327328
#[derive(Clone)]
328329
pub struct TlsAcceptor {
329330
cert: CertContext,
330-
min_protocol: Option<::Protocol>,
331-
max_protocol: Option<::Protocol>,
331+
min_protocol: Option<crate::Protocol>,
332+
max_protocol: Option<crate::Protocol>,
332333
}
333334

334335
impl TlsAcceptor {

src/imp/security_framework.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
extern crate libc;
2-
extern crate security_framework;
3-
extern crate security_framework_sys;
4-
5-
use self::security_framework::base;
6-
use self::security_framework::certificate::SecCertificate;
7-
use self::security_framework::identity::SecIdentity;
8-
use self::security_framework::import_export::{ImportedIdentity, Pkcs12ImportOptions};
9-
use self::security_framework::random::SecRandom;
10-
use self::security_framework::secure_transport::{
1+
use security_framework::base;
2+
use security_framework::certificate::SecCertificate;
3+
use security_framework::identity::SecIdentity;
4+
use security_framework::import_export::{ImportedIdentity, Pkcs12ImportOptions};
5+
use security_framework::random::SecRandom;
6+
use security_framework::secure_transport::{
117
self, ClientBuilder, SslConnectionType, SslContext, SslProtocol, SslProtocolSide,
128
};
13-
use self::security_framework_sys::base::{errSecIO, errSecParam};
9+
use security_framework_sys::base::{errSecIO, errSecParam};
1410
use std::error;
1511
use std::fmt;
1612
use std::io;
@@ -24,28 +20,28 @@ use std::sync::Once;
2420
target_os = "tvos",
2521
target_os = "visionos"
2622
)))]
27-
use self::security_framework::os::macos::certificate::{PropertyType, SecCertificateExt};
23+
use security_framework::os::macos::certificate::{PropertyType, SecCertificateExt};
2824
#[cfg(not(any(
2925
target_os = "ios",
3026
target_os = "watchos",
3127
target_os = "tvos",
3228
target_os = "visionos"
3329
)))]
34-
use self::security_framework::os::macos::certificate_oids::CertificateOid;
30+
use security_framework::os::macos::certificate_oids::CertificateOid;
3531
#[cfg(not(any(
3632
target_os = "ios",
3733
target_os = "watchos",
3834
target_os = "tvos",
3935
target_os = "visionos"
4036
)))]
41-
use self::security_framework::os::macos::identity::SecIdentityExt;
37+
use security_framework::os::macos::identity::SecIdentityExt;
4238
#[cfg(not(any(
4339
target_os = "ios",
4440
target_os = "watchos",
4541
target_os = "tvos",
4642
target_os = "visionos"
4743
)))]
48-
use self::security_framework::os::macos::import_export::{
44+
use security_framework::os::macos::import_export::{
4945
ImportOptions, Pkcs12ImportOptionsExt, SecItems,
5046
};
5147
#[cfg(not(any(
@@ -54,9 +50,9 @@ use self::security_framework::os::macos::import_export::{
5450
target_os = "tvos",
5551
target_os = "visionos"
5652
)))]
57-
use self::security_framework::os::macos::keychain::{self, KeychainSettings, SecKeychain};
53+
use security_framework::os::macos::keychain::{self, KeychainSettings, SecKeychain};
5854

59-
use {Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
55+
use crate::{Protocol, TlsAcceptorBuilder, TlsConnectorBuilder};
6056

6157
static SET_AT_EXIT: Once = Once::new();
6258

0 commit comments

Comments
 (0)