Compare commits

..

No commits in common. "main" and "v4.0.1" have entirely different histories.
main ... v4.0.1

6 changed files with 21 additions and 28 deletions

View file

@ -4,5 +4,6 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
kxio = "5.1" kxio = "5.0"
native-tls = { version = "0.2", features = ["vendored"] }
tokio = { version = "1.43", features = ["full"] } tokio = { version = "1.43", features = ["full"] }

View file

@ -39,7 +39,6 @@ RUN apk add --no-cache \
libssl3 \ libssl3 \
openssl-dev \ openssl-dev \
perl \ perl \
dbus-dev \
git git
# clang \ # clang \

View file

@ -42,7 +42,6 @@ The available toolchain in the image are:
- cargo-chef - cargo-chef
- cargo-hack - cargo-hack
- release-plz - release-plz
- dbus-dev
- perl - perl
### Scripts ### Scripts
@ -62,33 +61,10 @@ steps:
## Caveats ## Caveats
### openssl ### native-tls
The alpine linux install doesn't build with this dependency. You can either compile `native-tls` with the `vendored` feature, or not use `openssl`.
#### vendoered native-tls
This crate *must* use the `vendored` feature in order to compile in the Alpine Linux image. This crate *must* use the `vendored` feature in order to compile in the Alpine Linux image.
```toml ```toml
native-tls = { version = "0.2", features = ["vendored"] } native-tls = { version = "0.2", features = ["vendored"] }
``` ```
#### Don't use `openssl`
Check that none of your dependencies require `openssl`:
```bash
cargo tree --edges normal -i openssl
```
This will list the tree of dependencies that are bringing in `openssl`.
If you do need ssl/tls, try using `rustls`. e.g.
```toml
reqwest = { version = "0.12", default-features = false, features = [
"json",
"rustls-tls",
] }
```

View file

@ -1,4 +1,4 @@
image := "git.kemitix.net/kemitix/rust:test" image := "git.kemitix.get/kemitix/rust:test"
build: build:
docker build . -t {{ image }} docker build . -t {{ image }}

View file

@ -1,8 +1,10 @@
// //
mod kxio; mod kxio;
mod tls;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Hello, world!"); println!("Hello, world!");
tls::main();
let rt = tokio::runtime::Runtime::new()?; let rt = tokio::runtime::Runtime::new()?;
Ok(rt.block_on(crate::kxio::main())?) Ok(rt.block_on(crate::kxio::main())?)

15
src/tls.rs Normal file
View file

@ -0,0 +1,15 @@
use native_tls::TlsConnector;
use std::io::{Read, Write};
use std::net::TcpStream;
pub fn main() {
let connector = TlsConnector::new().unwrap();
let stream = TcpStream::connect("google.com:443").unwrap();
let mut stream = connector.connect("google.com", stream).unwrap();
stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap();
let mut res = vec![];
stream.read_to_end(&mut res).unwrap();
println!("{}", String::from_utf8_lossy(&res));
}