SSLSocketInitiator.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /* ====================================================================
4  * Copyright (c) 1998-2006 Ralf S. Engelschall. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials
16  * provided with the distribution.
17  *
18  * 3. All advertising materials mentioning features or use of this
19  * software must display the following acknowledgment:
20  * "This product includes software developed by
21  * Ralf S. Engelschall <rse@engelschall.com> for use in the
22  * mod_ssl project (http://www.modssl.org/)."
23  *
24  * 4. The names "mod_ssl" must not be used to endorse or promote
25  * products derived from this software without prior written
26  * permission. For written permission, please contact
27  * rse@engelschall.com.
28  *
29  * 5. Products derived from this software may not be called "mod_ssl"
30  * nor may "mod_ssl" appear in their names without prior
31  * written permission of Ralf S. Engelschall.
32  *
33  * 6. Redistributions of any form whatsoever must retain the following
34  * acknowledgment:
35  * "This product includes software developed by
36  * Ralf S. Engelschall <rse@engelschall.com> for use in the
37  * mod_ssl project (http://www.modssl.org/)."
38  *
39  * THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY
40  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR
43  * HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50  * OF THE POSSIBILITY OF SUCH DAMAGE.
51  * ====================================================================
52  */
53 
54 /* ====================================================================
55  * Copyright (c) 1995-1999 Ben Laurie. All rights reserved.
56  *
57  * Redistribution and use in source and binary forms, with or without
58  * modification, are permitted provided that the following conditions
59  * are met:
60  *
61  * 1. Redistributions of source code must retain the above copyright
62  * notice, this list of conditions and the following disclaimer.
63  *
64  * 2. Redistributions in binary form must reproduce the above copyright
65  * notice, this list of conditions and the following disclaimer in
66  * the documentation and/or other materials provided with the
67  * distribution.
68  *
69  * 3. All advertising materials mentioning features or use of this
70  * software must display the following acknowledgment:
71  * "This product includes software developed by Ben Laurie
72  * for use in the Apache-SSL HTTP server project."
73  *
74  * 4. The name "Apache-SSL Server" must not be used to
75  * endorse or promote products derived from this software without
76  * prior written permission.
77  *
78  * 5. Redistributions of any form whatsoever must retain the following
79  * acknowledgment:
80  * "This product includes software developed by Ben Laurie
81  * for use in the Apache-SSL HTTP server project."
82  *
83  * THIS SOFTWARE IS PROVIDED BY BEN LAURIE ``AS IS'' AND ANY
84  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
85  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
86  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BEN LAURIE OR
87  * HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
88  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
89  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
90  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
92  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
93  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
94  * OF THE POSSIBILITY OF SUCH DAMAGE.
95  * ====================================================================
96  */
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_SSLSOCKETINITIATOR_H
118 #define FIX_SSLSOCKETINITIATOR_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 "Initiator.h"
127 #include "SocketConnector.h"
128 #include "SSLSocketConnection.h"
129 
130 namespace FIX
131 {
133 class SSLSocketInitiator : public Initiator, SocketConnector::Strategy
134 {
135 public:
136  SSLSocketInitiator( Application&, MessageStoreFactory&,
137  const SessionSettings& ) throw( ConfigError );
138  SSLSocketInitiator( Application&, MessageStoreFactory&,
139  const SessionSettings&, LogFactory& ) throw( ConfigError );
140 
141  virtual ~SSLSocketInitiator();
142 
143  void setPassword(const std::string &pwd) { m_password.assign(pwd); }
144 
145  void setCertAndKey(X509 *cert, RSA *key)
146  {
147  m_cert = cert;
148  m_key = key;
149  }
150 
151  int passwordHandleCallback(char *buf, size_t bufsize, int verify, void *job);
152 
153  static int passwordHandleCB(char *buf, int bufsize, int verify, void *job);
154 
155 private:
156  typedef std::map < int, SSLSocketConnection* > SocketConnections;
157  typedef std::map < SessionID, int > SessionToHostNum;
158 
159  void onConfigure( const SessionSettings& ) throw ( ConfigError );
160  void onInitialize( const SessionSettings& ) throw ( RuntimeError );
161 
162  void onStart();
163  bool onPoll( double timeout );
164  void onStop();
165 
166  void doConnect( const SessionID&, const Dictionary& d );
167  void onConnect( SocketConnector&, int );
168  void onWrite( SocketConnector&, int );
169  bool onData( SocketConnector&, int );
170  void onDisconnect( SocketConnector&, int );
171  void onError( SocketConnector& );
172  void onTimeout( SocketConnector& );
173 
174  void getHost( const SessionID&, const Dictionary&, std::string&, short&, std::string&, short& );
175 
176  SessionToHostNum m_sessionToHostNum;
177  SocketConnector m_connector;
178  SocketConnections m_pendingConnections;
179  SocketConnections m_connections;
180  time_t m_lastConnect;
181  int m_reconnectInterval;
182  bool m_noDelay;
183  int m_sendBufSize;
184  int m_rcvBufSize;
185  bool m_sslInit;
186  SSL_CTX *m_ctx;
187  std::string m_password;
188  X509 *m_cert;
189  RSA *m_key;
190 };
192 }
193 
194 #endif
195 
196 #endif //FIX_SSLSOCKETINITIATOR_H
Initiator.h
FIX
Definition: Acceptor.cpp:34
SocketConnector.h
SSLSocketConnection.h

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001