19#include <isode/messages/ioevent.h>
23#include "../include/timeutil.h"
24#include "../include/EventSvc.h"
25#include "../include/PollInterface.h"
26#include "../include/SSLconfig.h"
27#include "../include/StreamInterface.h"
28#include "../include/DatagramInterface.h"
29#include <openssl/ssl.h>
37 extern Manager *CreateThreadManager ();
40 extern Manager *CreatePollManager ();
45 extern Provider *CreatePollpollProvider ();
48 extern Provider *CreatePollepollProvider ();
51 extern Provider *CreatePollselectProvider ();
54 extern Provider *CreatePollportProvider ();
59 extern Provider *CreateSocketPollProvider ();
64 extern Provider *CreateSocketPollProvider ();
68 static inline TLS_CipherSuite cipher_id(
const SSL_CIPHER*c) {
69 return SSL_CIPHER_get_id(c) & 0xffffff;
73 class OpenSSLContext :
public Context {
75 ICrypto::Environment::ptr_t envptr;
79 std::list<std::string> id_uris;
80 std::list<std::string> trust_anchor_uris;
81 bool dontTrustIdentities;
83 static pthread_mutex_t globalmutex;
84 static bool globalinit;
90 void loadCAsfromPEM (
const char *name);
92 void loadCertsFromFiles (
93 Config *confobj, std::list<std::string>& DER_files,
bool ista);
95 void convertLookupFlags (
int lookup_flags);
97 std::list<X509*> PullCertificates (
const std::list<std::string>& uris);
101 OpenSSLContext () : ctx(0), have_tls_id(false) {}
104 virtual ~OpenSSLContext ();
108 return available_suites;
113 return default_suites;
117 virtual bool HaveTLSIdentity () {
118 return ctx && SSL_CTX_get0_certificate (ctx) &&
119 SSL_CTX_get0_privatekey (ctx);
123 int Configure (Config *confobj, MSGstruct *msp);
126 SSL *GetSSL (tls_verify_client_choice &verifychoice);
130 std::list<X509*> ServerCertificates (
void);
133 static int Initialize (MSGstruct *msp);
135 std::list<X509*> GetTrustAnchors ()
const;
137 int GetTlsInfo (
const ICryptoKeyType keyType,
139 std::vector<std::string>& san,
140 std::vector<std::vector<unsigned char>>& cert_chain)
const;
142 size_t GetNbIdentities()
const;
146 extern int CheckHostname (X509 *cert,
const char *hostname, MSGstruct *msp);
149 extern int SSLError (MSGstruct *msp,
int msgno,
const char *ctx);
152 inline static void LogSSLError (
int msgno,
const char *ctx) {
153 if ( LOGGING_ID(msgno) ) {
155 SSLError (&lmsg, msgno, ctx);
tls_verify_client_choice
Values for choosing client verification.
std::set< TLS_CipherSuite > cipher_suites_t
Set of Cipher Suites (using the number)
Interface between a user of a datagram service and its provider.
Interface between a user of a stream and the provider of a stream.