From e234229ae80da0fa9967b797f7b5f4f381cba4b4 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 5 Apr 2020 14:22:31 +0200 Subject: All certificates configurable per site --- server_certificate.h | 67 ---------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 server_certificate.h (limited to 'server_certificate.h') diff --git a/server_certificate.h b/server_certificate.h deleted file mode 100644 index 1dc12a4..0000000 --- a/server_certificate.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP -#define BOOST_BEAST_EXAMPLE_COMMON_SERVER_CERTIFICATE_HPP - -#include -#include -#include -#include - -#include "config.h" -#include "file.h" - -/* Load a signed certificate into the ssl context, and configure - the context for use with a server. - - For this to work with the browser or operating system, it is - necessary to import the "Beast Test CA" certificate into - the local certificate store, browser, or operating system - depending on your environment Please see the documentation - accompanying the Beast certificate for more details. -*/ -inline -void -load_server_certificate(boost::asio::ssl::context& ctx, fs::path cert_path, fs::path key_path) -{ - /* - The certificate was generated from CMD.EXE on Windows 10 using: - - winpty openssl dhparam -out dh.pem 2048 - winpty openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 10000 -out cert.pem -subj "//C=US\ST=CA\L=Los Angeles\O=Beast\CN=www.example.com" - */ - - std::string const cert = File::getFile(cert_path); - std::string const key = File::getFile(key_path); - std::string const dh = - "-----BEGIN DH PARAMETERS-----\n" - "MIIBCAKCAQEArzQc5mpm0Fs8yahDeySj31JZlwEphUdZ9StM2D8+Fo7TMduGtSi+\n" - "/HRWVwHcTFAgrxVdm+dl474mOUqqaz4MpzIb6+6OVfWHbQJmXPepZKyu4LgUPvY/\n" - "4q3/iDMjIS0fLOu/bLuObwU5ccZmDgfhmz1GanRlTQOiYRty3FiOATWZBRh6uv4u\n" - "tff4A9Bm3V9tLx9S6djq31w31Gl7OQhryodW28kc16t9TvO1BzcV3HjRPwpe701X\n" - "oEEZdnZWANkkpR/m/pfgdmGPU66S2sXMHgsliViQWpDCYeehrvFRHEdR9NV+XJfC\n" - "QMUk26jPTIVTLfXmmwU0u8vUkpR7LQKkwwIBAg==\n" - "-----END DH PARAMETERS-----\n"; - - ctx.set_password_callback( - [](std::size_t, - boost::asio::ssl::context_base::password_purpose) - { - return "test"; - }); - - ctx.set_options( - boost::asio::ssl::context::default_workarounds | - boost::asio::ssl::context::no_sslv2 | - boost::asio::ssl::context::single_dh_use); - - ctx.use_certificate_chain( - boost::asio::buffer(cert.data(), cert.size())); - - ctx.use_private_key( - boost::asio::buffer(key.data(), key.size()), - boost::asio::ssl::context::file_format::pem); - - ctx.use_tmp_dh( - boost::asio::buffer(dh.data(), dh.size())); -} - -#endif -- cgit v1.2.3