mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:52:44 +00:00 
			
		
		
		
	 aafc451016
			
		
	
	
		aafc451016
		
	
	
	
	
		
			
			This commit converts TLS::TLSv12 to a Core::Stream object, and in the process allows TLS to now wrap other Core::Stream::Socket objects. As a large part of LibHTTP and LibGemini depend on LibTLS's interface, this also converts those to support Core::Stream, which leads to a simplification of LibHTTP (as there's no need to care about the underlying socket type anymore). Note that RequestServer now controls the TLS socket options, which is a better place anyway, as RS is the first receiver of the user-requested options (though this is currently not particularly useful).
		
			
				
	
	
		
			42 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * 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;
 | |
| };
 | |
| 
 | |
| }
 |