summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibHTTP/HttpsJob.h
blob: 32a9bcc7b2a76365c7d87f03acc4206adcfad773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright (c) 2020, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/HashMap.h>
#include <LibCore/NetworkJob.h>
#include <LibCore/Stream.h>
#include <LibHTTP/HttpRequest.h>
#include <LibHTTP/HttpResponse.h>
#include <LibHTTP/Job.h>
#include <LibTLS/TLSv12.h>

namespace HTTP {

class HttpsJob final : public Job {
    C_OBJECT(HttpsJob)
public:
    virtual ~HttpsJob() override
    {
    }

    bool received_client_certificates() const { return m_received_client_certificates.has_value(); }
    Vector<TLS::Certificate> take_client_certificates() const { return m_received_client_certificates.release_value(); }

    void set_certificate(String certificate, String key);

    Function<Vector<TLS::Certificate>()> on_certificate_requested;

private:
    explicit HttpsJob(HttpRequest&& request, Core::Stream::Stream& output_stream)
        : Job(move(request), output_stream)
    {
    }

    mutable Optional<Vector<TLS::Certificate>> m_received_client_certificates;
};

}