forked from blackbeam/mysql_async
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from second-state/feat/wasi_tls
Feat/wasi tls
- Loading branch information
Showing
8 changed files
with
136 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#![cfg(any(feature = "native-tls", feature = "rustls"))] | ||
#![cfg(any(feature = "native-tls", feature = "rustls", feature = "wasmedge-tls"))] | ||
|
||
mod native_tls_io; | ||
mod rustls_io; | ||
mod wasmedge_rustls_io; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#![cfg(feature = "wasmedge-tls")] | ||
|
||
use wasmedge_rustls_api::{stream::async_stream::TlsStream, ClientConfig}; | ||
|
||
use crate::{io::Endpoint, Result}; | ||
|
||
impl Endpoint { | ||
pub async fn make_secure(&mut self, domain: String, _ssl_opts: crate::SslOpts) -> Result<()> { | ||
#[cfg(unix)] | ||
if self.is_socket() { | ||
// won't secure socket connection | ||
return Ok(()); | ||
} | ||
|
||
let config = ClientConfig::default(); | ||
|
||
*self = match self { | ||
Endpoint::Plain(ref mut stream) => { | ||
let stream = stream.take().unwrap(); | ||
|
||
let connection = TlsStream::connect(&config, domain, stream) | ||
.await | ||
.map_err(|e| e.0)?; | ||
|
||
Endpoint::Secure(connection) | ||
} | ||
Endpoint::Secure(_) => unreachable!(), | ||
#[cfg(unix)] | ||
Endpoint::Socket(_) => unreachable!(), | ||
}; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters