SSLSocketAcceptor.h
Go to the documentation of this file.
1/* ====================================================================
2 * Copyright (c) 1998-2006 Ralf S. Engelschall. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by
19 * Ralf S. Engelschall <rse@engelschall.com> for use in the
20 * mod_ssl project (http://www.modssl.org/)."
21 *
22 * 4. The names "mod_ssl" must not be used to endorse or promote
23 * products derived from this software without prior written
24 * permission. For written permission, please contact
25 * rse@engelschall.com.
26 *
27 * 5. Products derived from this software may not be called "mod_ssl"
28 * nor may "mod_ssl" appear in their names without prior
29 * written permission of Ralf S. Engelschall.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by
34 * Ralf S. Engelschall <rse@engelschall.com> for use in the
35 * mod_ssl project (http://www.modssl.org/)."
36 *
37 * THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY
38 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR
41 * HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 * OF THE POSSIBILITY OF SUCH DAMAGE.
49 * ====================================================================
50 */
51
52/* ====================================================================
53 * Copyright (c) 1995-1999 Ben Laurie. All rights reserved.
54 *
55 * Redistribution and use in source and binary forms, with or without
56 * modification, are permitted provided that the following conditions
57 * are met:
58 *
59 * 1. Redistributions of source code must retain the above copyright
60 * notice, this list of conditions and the following disclaimer.
61 *
62 * 2. Redistributions in binary form must reproduce the above copyright
63 * notice, this list of conditions and the following disclaimer in
64 * the documentation and/or other materials provided with the
65 * distribution.
66 *
67 * 3. All advertising materials mentioning features or use of this
68 * software must display the following acknowledgment:
69 * "This product includes software developed by Ben Laurie
70 * for use in the Apache-SSL HTTP server project."
71 *
72 * 4. The name "Apache-SSL Server" must not be used to
73 * endorse or promote products derived from this software without
74 * prior written permission.
75 *
76 * 5. Redistributions of any form whatsoever must retain the following
77 * acknowledgment:
78 * "This product includes software developed by Ben Laurie
79 * for use in the Apache-SSL HTTP server project."
80 *
81 * THIS SOFTWARE IS PROVIDED BY BEN LAURIE ``AS IS'' AND ANY
82 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
83 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
84 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BEN LAURIE OR
85 * HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
86 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
87 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
88 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
89 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
90 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
91 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
92 * OF THE POSSIBILITY OF SUCH DAMAGE.
93 * ====================================================================
94 */
95
96/* -*- C++ -*- */
97
98/****************************************************************************
99** Copyright (c) 2001-2014
100**
101** This file is part of the QuickFIX FIX Engine
102**
103** This file may be distributed under the terms of the quickfixengine.org
104** license as defined by quickfixengine.org and appearing in the file
105** LICENSE included in the packaging of this file.
106**
107** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
108** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
109**
110** See http://www.quickfixengine.org/LICENSE for licensing information.
111**
112** Contact ask@quickfixengine.org if any conditions of this licensing are
113** not clear to you.
114**
115****************************************************************************/
116
117#ifndef FIX_SSLSOCKETACCEPTOR_H
118#define FIX_SSLSOCKETACCEPTOR_H
119
120#if (HAVE_SSL > 0)
121
122#ifdef _MSC_VER
123#pragma warning( disable : 4503 4355 4786 4290 )
124#endif
125
126#include "Acceptor.h"
127#include "SocketServer.h"
128#include "SSLSocketConnection.h"
129
130namespace FIX
131{
133class SSLSocketAcceptor : public Acceptor, SocketServer::Strategy
134{
135 friend class SSLSocketConnection;
136public:
137 SSLSocketAcceptor( Application&, MessageStoreFactory&,
138 const SessionSettings& ) throw( ConfigError );
139 SSLSocketAcceptor( Application&, MessageStoreFactory&,
140 const SessionSettings&, LogFactory& ) throw( ConfigError );
141
142 virtual ~SSLSocketAcceptor();
143
144 void setPassword(const std::string &pwd) { m_password.assign(pwd); }
145
146 int passwordHandleCallback(char *buf, size_t bufsize, int verify, void *job);
147
148 static int passPhraseHandleCB(char *buf, int bufsize, int verify, void *job);
149
150private:
151 bool readSettings( const SessionSettings& );
152
153 typedef std::set < SessionID > Sessions;
154 typedef std::map < int, Sessions > PortToSessions;
155 typedef std::map < int, SSLSocketConnection* > SocketConnections;
156
157 void onConfigure( const SessionSettings& ) throw ( ConfigError );
158 void onInitialize( const SessionSettings& ) throw ( RuntimeError );
159
160 void onStart();
161 bool onPoll( double timeout );
162 void onStop();
163
164 void onConnect( SocketServer&, int, int );
165 void onWrite( SocketServer&, int );
166 bool onData( SocketServer&, int );
167 void onDisconnect( SocketServer&, int );
168 void onError( SocketServer& );
169 void onTimeout( SocketServer& );
170
171 SocketServer* m_pServer;
172 PortToSessions m_portToSessions;
173 SocketConnections m_connections;
174
175 bool m_sslInit;
176 int m_verify;
177 SSL_CTX *m_ctx;
178 X509_STORE *m_revocationStore;
179 std::string m_password;
180};
182}
183
184#endif
185#endif //FIX_SSLSOCKETACCEPTOR_H

Generated on Mon Oct 14 2024 06:04:44 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001