Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: example server crash on insecure SSL #40

Merged
2 commits merged into from Apr 28, 2020
Merged

fix: example server crash on insecure SSL #40

2 commits merged into from Apr 28, 2020

Conversation

alexeldeib
Copy link
Contributor

Fixes the async-h1-server example in case of insecure SSL connection

before:

ace@ace-home-vm:~/code/smol/examples$ cargo run --example async-h1-server
   Compiling smol-examples v0.0.0 (/home/ace/code/smol/examples)
    Finished dev [unoptimized + debuginfo] target(s) in 2.53s
     Running `/home/ace/code/smol/target/debug/examples/async-h1-server`
Listening on http://127.0.0.1:8000
Listening on https://127.0.0.1:8001
Error: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca:../ssl/record/rec_layer_s3.c:1528:SSL alert number 48

Caused by:
    error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca:../ssl/record/rec_layer_s3.c:1528:SSL alert number 48
ace@ace-home-vm:~/code/smol/examples$ 

after:

ace@ace-home-vm:~/code/smol/examples$ cargo run --example async-h1-server
   Compiling smol-examples v0.0.0 (/home/ace/code/smol/examples)
    Finished dev [unoptimized + debuginfo] target(s) in 2.69s
     Running `/home/ace/code/smol/target/debug/examples/async-h1-server`
Listening on http://127.0.0.1:8000
Listening on https://127.0.0.1:8001
Failed to establish secure TLS connection: Ssl(
    Error {
        code: ErrorCode(
            1,
        ),
        cause: Some(
            Ssl(
                ErrorStack(
                    [
                        Error {
                            code: 336151576,
                            library: "SSL routines",
                            function: "ssl3_read_bytes",
                            reason: "tlsv1 alert unknown ca",
                            file: "../ssl/record/rec_layer_s3.c",
                            line: 1528,
                            data: "SSL alert number 48",
                        },
                    ],
                ),
            ),
        ),
    },
    X509VerifyResult {
        code: 0,
        error: "ok",
    },
)

@alexeldeib
Copy link
Contributor Author

alexeldeib commented Apr 27, 2020

simple-server has the same problem, but because of how the task gets spawned off it's not immediately clear to me what the best way to handle the error is. Maybe just:

Task::spawn(serve(stream, tls.clone())).expect("failed to serve request").detach();

?

I know it's just an example, so maybe the panics are fine.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I've already got simple-server working so I'll apply these changes to it :)

@ghost ghost merged commit 339b9d1 into smol-rs:master Apr 28, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant