Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
899f201
feat: SSL Session
algebraic-dev Jun 16, 2026
b7782ae
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Jun 16, 2026
1c628b6
fix: read 0 bug
algebraic-dev Jun 16, 2026
29dda2e
fix: add clear error in session functions
algebraic-dev Jun 16, 2026
38b1359
fix: max size of recv?
algebraic-dev Jun 16, 2026
a41fa06
feat: unespecified
algebraic-dev Jun 17, 2026
db48940
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Jun 18, 2026
ece36f9
test: fix path of tests
algebraic-dev Jun 18, 2026
5ddc34d
test: tempdir for tests
algebraic-dev Jun 18, 2026
28e9f5f
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Jun 18, 2026
bbdc510
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Jun 27, 2026
23b638b
fix: comments and set server name
algebraic-dev Jun 27, 2026
63c4803
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Jul 4, 2026
ee23663
test: configure + mk
algebraic-dev Jul 4, 2026
d7a31de
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Jul 4, 2026
08e9ae7
test: make it not depend on openssl cli
algebraic-dev Jul 4, 2026
75bb128
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 12, 2026
403d399
fix: close notify half-close
algebraic-dev Aug 15, 2026
76bb4ed
fix: close notify
algebraic-dev Aug 15, 2026
ba4d710
feat: add feed eof
algebraic-dev Aug 15, 2026
532bea1
fix: comments, max size of queue and close notify
algebraic-dev Aug 15, 2026
a2cf835
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 15, 2026
1036c92
feat: add ssl invalid argument
algebraic-dev Aug 15, 2026
14718ce
refactor: simplify
algebraic-dev Aug 15, 2026
6584d74
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 15, 2026
8887a66
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 15, 2026
fa43ddb
fix: fail state
algebraic-dev Aug 16, 2026
f50b18f
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 18, 2026
34ffa74
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 19, 2026
c68d408
fix: lots of surfaces of attack
algebraic-dev Aug 19, 2026
608722e
fix: build failure on non-macOS from unused keychain globals
algebraic-dev Aug 20, 2026
7c224e1
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 20, 2026
8f2b63f
chore: make comments better
algebraic-dev Aug 20, 2026
9d3c417
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 20, 2026
8ffaa15
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 20, 2026
b5301b6
fix: small issues related to comments
algebraic-dev Aug 21, 2026
35564ba
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Aug 23, 2026
0059ff2
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Sep 1, 2026
990e734
fix: no compression
algebraic-dev Sep 2, 2026
f0d70ad
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Sep 2, 2026
71f4f2d
test: delete dirs after testing
algebraic-dev Sep 2, 2026
2cb915b
Merge branch 'sofia/openssl-socket-context' into sofia/openssl-socket…
algebraic-dev Sep 2, 2026
973fce4
fix: tests, adapt to capture exceptions
algebraic-dev Sep 2, 2026
5eaf0ad
fix: comments
algebraic-dev Sep 2, 2026
28a6d08
refactor: simplify want_read
algebraic-dev Sep 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Std/Internal/SSL.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Authors: Sofia Rodrigues
module
prelude
public import Std.Internal.SSL.Context
public import Std.Internal.SSL.Session
397 changes: 397 additions & 0 deletions src/Std/Internal/SSL/Session.lean

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ set(
uv/signal.cpp
openssl.cpp
openssl/context.cpp
openssl/session.cpp
openssl/ssl_error.cpp
openssl/trust_store.cpp
)
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/init_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Author: Leonardo de Moura
#include "runtime/libuv.h"
#include "runtime/openssl.h"
#include "runtime/openssl/context.h"
#include "runtime/openssl/session.h"

namespace lean {
// idempotent as it may be called both by the generated `main` and, via `lean_initialize`,
Expand All @@ -35,6 +36,7 @@ extern "C" LEAN_EXPORT void lean_initialize_runtime_module() {
initialize_stack_overflow();
initialize_openssl();
initialize_openssl_context();
initialize_openssl_session();
initialize_libuv();
}
void initialize_runtime_module() {
Expand Down
23 changes: 5 additions & 18 deletions src/runtime/openssl/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ static void configure_ctx_options(SSL_CTX * ctx) {

// Disables RFC 5077 session tickets in TLS 1.2. In TLS 1.3 it only downgrades them to the
// stateful form; the call below is what stops those being sent.
SSL_OP_NO_TICKET
SSL_OP_NO_TICKET |

// TLS 1.2 and below only; TLS 1.3 has no compression. A libssl built against zlib and
// running at security level 1 would otherwise negotiate it, which is CRIME.
SSL_OP_NO_COMPRESSION
);

// Without this a TLS 1.3 server still puts two NewSessionTickets on the wire per connection.
Expand Down Expand Up @@ -355,23 +359,6 @@ static lean_obj_res mk_client_ctx_checked(b_obj_arg ca, uint8_t ca_is_file, uint
return mk_client_ctx(verify_peer, trust_system_roots, allow_partial_chain, has_ca != 0, ca_src);
}

// Runs a constructor behind the two guards every entry point needs: OpenSSL initialized before any
// `ERR_*` call can register `atexit(OPENSSL_cleanup)` behind `OPENSSL_INIT_NO_ATEXIT`'s back, and no
// C++ exception escaping into Lean-generated code.
template<typename F>
static lean_obj_res ssl_entry_point(F && build) {
try {
if (!ensure_openssl_initialized()) {
return lean_io_result_mk_error(lean_mk_io_user_error(
mk_string("OPENSSL_init_ssl failed")));
}

return build();
} catch (std::exception & ex) {
return lean_io_result_mk_error(lean_mk_io_user_error(mk_string(ex.what())));
}
}

/* Std.Internal.SSL.Context.Server.mkImpl (cert : @& String) (certIsFile : Bool) (key : @& String) (keyIsFile : Bool) : IO Context.Server */
extern "C" LEAN_EXPORT lean_obj_res lean_ssl_ctx_mk_server(b_obj_arg cert, uint8_t cert_is_file, b_obj_arg key, uint8_t key_is_file) {
return ssl_entry_point([&] { return mk_server_ctx(cert, cert_is_file, key, key_is_file); });
Expand Down
Loading
Loading