Skip to content

Commit 95704ba

Browse files
committed
Introducing the Boring crypto provider.
Also adding examples and basic documentation.
1 parent 3621968 commit 95704ba

28 files changed

+5689
-50
lines changed

.github/workflows/rust.yml

Lines changed: 85 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,125 @@ on:
88
- cron: "21 3 * * 5"
99

1010
jobs:
11-
test-freebsd:
12-
# see https://github.com/actions/runner/issues/385
13-
# use https://github.com/vmactions/freebsd-vm for now
14-
name: test on freebsd
15-
runs-on: macos-12
16-
steps:
17-
- uses: actions/checkout@v2
18-
- name: test on freebsd
19-
uses: vmactions/freebsd-vm@v0
20-
with:
21-
usesh: true
22-
mem: 4096
23-
copyback: false
24-
prepare: |
25-
pkg install -y curl
26-
curl https://sh.rustup.rs -sSf --output rustup.sh
27-
sh rustup.sh -y --profile minimal --default-toolchain stable
28-
echo "~~~~ rustc --version ~~~~"
29-
$HOME/.cargo/bin/rustc --version
30-
run: |
31-
freebsd-version
32-
$HOME/.cargo/bin/cargo build --all-targets
33-
$HOME/.cargo/bin/cargo test
11+
12+
# TODO(nmittler): Investigate why tests get "unknown CA" on windows.
13+
# test-windows:
14+
# name: test (windows-latest, stable)
15+
# runs-on: windows-latest
16+
#
17+
# steps:
18+
# - name: Checkout source
19+
# uses: actions/checkout@v2
20+
# with:
21+
# submodules: 'recursive'
22+
# - name: Install nasm
23+
# uses: crazy-max/ghaction-chocolatey@v1
24+
# with:
25+
# args: install nasm
26+
# - name: Install rust toolchain
27+
# uses: actions-rs/toolchain@v1
28+
# with:
29+
# profile: minimal
30+
# toolchain: stable
31+
# override: true
32+
# - name: Cargo Build
33+
# uses: actions-rs/cargo@v1
34+
# with:
35+
# command: build
36+
# args: --all-targets
37+
# - name: Cargo Test
38+
# uses: actions-rs/cargo@v1
39+
# with:
40+
# command: test
41+
# args: --verbose --all-targets
42+
3443
test:
3544
strategy:
3645
matrix:
37-
os: [ubuntu-latest, macos-latest, windows-latest]
38-
rust: [stable, beta, 1.59.0]
46+
os: [ubuntu-latest, macos-latest]
47+
rust: [stable, beta]
3948
exclude:
4049
- os: macos-latest
4150
rust: beta
42-
- os: macos-latest
43-
rust: 1.59.0
44-
- os: windows-latest
45-
rust: beta
46-
- os: windows-latest
47-
rust: 1.59.0
4851

4952
runs-on: ${{ matrix.os }}
5053

5154
steps:
52-
- uses: actions/checkout@v2
53-
- uses: actions-rs/toolchain@v1
55+
- name: Checkout source
56+
uses: actions/checkout@v2
57+
with:
58+
submodules: 'recursive'
59+
- name: Install rust toolchain
60+
uses: actions-rs/toolchain@v1
5461
with:
5562
profile: minimal
5663
toolchain: ${{ matrix.rust }}
5764
override: true
58-
- uses: Swatinem/rust-cache@v1
59-
- uses: actions-rs/cargo@v1
65+
- name: Cargo Build
66+
uses: actions-rs/cargo@v1
6067
with:
6168
command: build
6269
args: --all-targets
63-
- uses: actions-rs/cargo@v1
70+
- name: Cargo Test
71+
uses: actions-rs/cargo@v1
6472
with:
6573
command: test
6674

75+
# TODO(nmittler): Investigate build issues.
76+
# test-fips:
77+
# name: test fips
78+
# runs-on: ubuntu-20.04
79+
# steps:
80+
# - name: Checkout source
81+
# uses: actions/checkout@v2
82+
# with:
83+
# submodules: 'recursive'
84+
# - name: Install Clang 7
85+
# uses: egor-tensin/setup-clang@v1
86+
# with:
87+
# version: "7"
88+
# - name: Install rust toolchain
89+
# uses: actions-rs/toolchain@v1
90+
# with:
91+
# profile: minimal
92+
# toolchain: stable
93+
# override: true
94+
# - name: Cargo Build
95+
# uses: actions-rs/cargo@v1
96+
# with:
97+
# command: build
98+
# args: --all-targets --features fips
99+
# - name: Cargo Test
100+
# uses: actions-rs/cargo@v1
101+
# with:
102+
# command: test
103+
# args: --features fips
104+
67105
lint:
68106
runs-on: ubuntu-latest
69107
steps:
70-
- uses: actions/checkout@v2
71-
- uses: actions-rs/toolchain@v1
108+
- name: Checkout source
109+
uses: actions/checkout@v2
110+
with:
111+
submodules: 'recursive'
112+
- name: Install rust toolchain
113+
uses: actions-rs/toolchain@v1
72114
with:
73115
profile: minimal
74116
toolchain: stable
75117
override: true
76118
components: rustfmt, clippy
77-
- uses: Swatinem/rust-cache@v1
78-
- uses: actions-rs/cargo@v1
119+
- name: Cargo fmt
120+
uses: actions-rs/cargo@v1
79121
with:
80122
command: fmt
81123
args: --all -- --check
82-
- uses: actions-rs/cargo@v1
124+
- name: Cargo clippy
125+
uses: actions-rs/cargo@v1
83126
with:
84127
command: clippy
85128
args: --all-targets -- -D warnings
86-
- uses: actions-rs/toolchain@v1
87-
with:
88-
profile: minimal
89-
toolchain: stable
90-
override: true
91-
components: clippy
92-
- name: doc
129+
- name: Cargo doc
93130
run: cargo doc --no-deps --document-private-items
94131
env:
95132
RUSTDOCFLAGS: -Dwarnings

Cargo.toml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,42 @@ description = "BoringSSL crypto provider for quinn"
77
keywords = ["quic"]
88
categories = ["network-programming", "asynchronous"]
99
edition = "2021"
10-
rust-version = "1.59"
1110

1211
[badges]
1312
maintenance = { status = "passively-maintained" }
1413

14+
[features]
15+
fips = ["boring/fips", "boring-sys/fips"]
16+
1517
[dependencies]
18+
boring = "2.1.0"
19+
boring-sys = "2.1.0"
20+
bytes = "1"
21+
foreign-types-shared = "0.3.1"
22+
lru = "0.9.0"
23+
once_cell = "1.17"
24+
quinn = { version = "0.9.3", default_features = false, features = ["native-certs", "runtime-tokio"] }
25+
quinn-proto = { version = "0.9.3", default-features = false }
26+
rand = "0.8"
27+
tracing = "0.1"
28+
29+
[dev-dependencies]
30+
anyhow = "1.0.22"
31+
assert_hex = "0.2.2"
32+
assert_matches = "1.1"
33+
clap = { version = "3.2", features = ["derive"] }
34+
directories-next = "2"
35+
hex-literal = "0.3.0"
36+
ring = "0.16.7"
37+
rcgen = "0.10.0"
38+
rustls-pemfile = "1.0.0"
39+
tokio = { version = "1.0.1", features = ["rt", "rt-multi-thread", "time", "macros", "sync"] }
40+
tracing-futures = { version = "0.2.0", default-features = false, features = ["std-future"] }
41+
tracing-subscriber = { version = "0.3.0", default-features = false, features = ["env-filter", "fmt", "ansi", "time", "local-time"] }
42+
url = "2"
43+
44+
[[example]]
45+
name = "server"
46+
47+
[[example]]
48+
name = "client"

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
1-
# TODO
1+
[![codecov](https://codecov.io/gh/quinn-rs/quinn/branch/main/graph/badge.svg)](https://codecov.io/gh/quinn-rs/quinn-boring)
2+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE-MIT)
3+
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE-APACHE)
4+
5+
A crypto provider for [quinn](https://github.com/quinn-rs/quinn) based on [BoringSSL](https://github.com/google/boringssl).
6+
7+
## Getting Started
8+
9+
The [examples](examples) directory provides example client and server applications, which can be run as follows:
10+
11+
```sh
12+
$ cargo run --example server ./
13+
$ cargo run --example client https://localhost:4433/Cargo.toml
14+
```
15+
16+
This launches an HTTP 0.9 server on the loopback address serving the current
17+
working directory, with the client fetching `./Cargo.toml`. By default, the
18+
server generates a self-signed certificate and stores it to disk, where the
19+
client will automatically find and trust it.
20+
21+
## Testing
22+
23+
This repository relies on the [quinn_proto integration tests](https://github.com/quinn-rs/quinn/tree/main/quinn-proto/src/tests),
24+
which can be made to run with the BoringSSL provider.
25+
26+
## FIPS
27+
28+
The BoringSSL provider is based on the Cloudflare [Boring library](https://github.com/cloudflare/boring), which
29+
supports building against a FIPS-validated version of BoringSSL.
30+
31+
## Authors
32+
33+
* [Nathan Mittler](https://github.com/nmittler) - *Project owner*

deny.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[licenses]
2+
allow-osi-fsf-free = "either"
3+
copyleft = "warn"
4+
exceptions = [{ allow = ["ISC", "MIT", "OpenSSL"], name = "ring" }]
5+
private = { ignore = true }
6+
7+
[[licenses.clarify]]
8+
name = "ring"
9+
expression = "ISC AND MIT AND OpenSSL"
10+
license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]

examples/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## HTTP/0.9 File Serving Example
2+
3+
The examples in this directory were copied from [quinn](https://github.com/quinn-rs/quinn/tree/main/quinn/examples)
4+
and modified to use BoringSSL.
5+
6+
The `server` and `client` examples demonstrate fetching files using a HTTP-like toy protocol.
7+
8+
1. Server (`server.rs`)
9+
10+
The server listens for any client requesting a file.
11+
If the file path is valid and allowed, it returns the contents.
12+
13+
Open up a terminal and execute:
14+
15+
```text
16+
$ cargo run --example server ./
17+
```
18+
19+
2. Client (`client.rs`)
20+
21+
The client requests a file and prints it to the console.
22+
If the file is on the server, it will receive the response.
23+
24+
In a new terminal execute:
25+
26+
```test
27+
$ cargo run --example client https://localhost:4433/Cargo.toml
28+
```
29+
30+
where `Cargo.toml` is any file in the directory passed to the server.
31+
32+
**Result:**
33+
34+
The output will be the contents of this README.
35+
36+
**Troubleshooting:**
37+
38+
If the client times out with no activity on the server, try forcing the server to run on IPv4 by
39+
running it with `cargo run --example server -- ./ --listen 127.0.0.1:4433`. The server listens on
40+
IPv6 by default, `localhost` tends to resolve to IPv4, and support for accepting IPv4 packets on
41+
IPv6 sockets varies between platforms.
42+
43+
If the client prints `failed to process request: failed reading file`, the request was processed
44+
successfully but the path segment of the URL did not correspond to a file in the directory being
45+
served.

0 commit comments

Comments
 (0)