1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

ProtocolServer+LibTLS: Pipe certificate requests from LibTLS to clients

This makes gemini.circumlunar.space (and some more gemini pages) work
again :^)
This commit is contained in:
AnotherTest 2020-08-02 05:27:42 +04:30 committed by Andreas Kling
parent 9d3ffa096a
commit 97256ad977
22 changed files with 161 additions and 3 deletions

View file

@ -63,6 +63,10 @@ void GeminiJob::start()
m_socket->on_tls_finished = [this] {
finish_up();
};
m_socket->on_tls_certificate_request = [this](auto&) {
if (on_certificate_requested)
on_certificate_requested(*this);
};
bool success = ((TLS::TLSv12&)*m_socket).connect(m_request.url().host(), m_request.url().port());
if (!success) {
deferred_invoke([this](auto&) {
@ -89,6 +93,15 @@ void GeminiJob::read_while_data_available(Function<IterationDecision()> read)
}
}
void GeminiJob::set_certificate(String certificate, String private_key)
{
if (!m_socket->add_client_key(ByteBuffer::wrap(certificate.characters(), certificate.length()), ByteBuffer::wrap(private_key.characters(), private_key.length()))) {
dbg() << "LibGemini: Failed to set a client certificate";
// FIXME: Do something about this failure
ASSERT_NOT_REACHED();
}
}
void GeminiJob::register_on_ready_to_read(Function<void()> callback)
{
m_socket->on_tls_ready_to_read = [callback = move(callback)](auto&) {