mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +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:
parent
9d3ffa096a
commit
97256ad977
22 changed files with 161 additions and 3 deletions
|
@ -64,6 +64,10 @@ void HttpsJob::start()
|
|||
m_socket->on_tls_finished = [&] {
|
||||
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&) {
|
||||
|
@ -82,6 +86,15 @@ void HttpsJob::shutdown()
|
|||
m_socket = nullptr;
|
||||
}
|
||||
|
||||
void HttpsJob::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() << "LibHTTP: Failed to set a client certificate";
|
||||
// FIXME: Do something about this failure
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void HttpsJob::read_while_data_available(Function<IterationDecision()> read)
|
||||
{
|
||||
while (m_socket->can_read()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue