zeroc-ice 3.8.2 → 3.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. checksums.yaml +4 -4
  2. data/dist/IceRuby/Communicator.cpp +26 -9
  3. data/dist/IceRuby/Config.h +0 -12
  4. data/dist/IceRuby/Connection.cpp +18 -9
  5. data/dist/IceRuby/DefaultSliceLoader.h +1 -1
  6. data/dist/IceRuby/Endpoint.cpp +21 -8
  7. data/dist/IceRuby/Operation.cpp +7 -5
  8. data/dist/IceRuby/Properties.cpp +3 -4
  9. data/dist/IceRuby/Proxy.cpp +11 -19
  10. data/dist/IceRuby/RubySliceLoader.cpp +1 -1
  11. data/dist/IceRuby/RubySliceLoader.h +6 -0
  12. data/dist/IceRuby/Types.cpp +162 -138
  13. data/dist/IceRuby/Types.h +68 -28
  14. data/dist/IceRuby/Util.cpp +14 -78
  15. data/dist/IceRuby/Util.h +7 -17
  16. data/dist/ice/cpp/include/Ice/Communicator.h +31 -8
  17. data/dist/ice/cpp/include/Ice/Config.h +2 -2
  18. data/dist/ice/cpp/include/Ice/Connection.h +24 -8
  19. data/dist/ice/cpp/include/Ice/CtrlCHandler.h +1 -1
  20. data/dist/ice/cpp/include/Ice/Demangle.h +1 -1
  21. data/dist/ice/cpp/include/Ice/Endpoint.h +4 -4
  22. data/dist/ice/cpp/include/Ice/Initialize.h +4 -4
  23. data/dist/ice/cpp/include/Ice/InputStream.h +5 -5
  24. data/dist/ice/cpp/include/Ice/Instrumentation.h +13 -7
  25. data/dist/ice/cpp/include/Ice/LocalExceptions.h +5 -5
  26. data/dist/ice/cpp/include/Ice/Logger.h +7 -0
  27. data/dist/ice/cpp/include/Ice/LoggerUtil.h +1 -1
  28. data/dist/ice/cpp/include/Ice/Object.h +10 -8
  29. data/dist/ice/cpp/include/Ice/ObjectAdapter.h +1 -1
  30. data/dist/ice/cpp/include/Ice/OutgoingAsync.h +5 -2
  31. data/dist/ice/cpp/include/Ice/OutgoingResponse.h +2 -1
  32. data/dist/ice/cpp/include/Ice/OutputStream.h +7 -6
  33. data/dist/ice/cpp/include/Ice/PluginFactory.h +1 -1
  34. data/dist/ice/cpp/include/Ice/Properties.h +3 -3
  35. data/dist/ice/cpp/include/Ice/Proxy.h +192 -50
  36. data/dist/ice/cpp/include/Ice/SSL/ClientAuthenticationOptions.h +3 -3
  37. data/dist/ice/cpp/include/Ice/SSL/EndpointInfo.h +1 -1
  38. data/dist/ice/cpp/include/Ice/SSL/ServerAuthenticationOptions.h +5 -5
  39. data/dist/ice/cpp/include/Ice/ServantLocator.h +1 -1
  40. data/dist/ice/cpp/include/Ice/Service.h +2 -5
  41. data/dist/ice/cpp/include/Ice/SliceLoader.h +1 -1
  42. data/dist/ice/cpp/include/Ice/SlicedData.h +5 -3
  43. data/dist/ice/cpp/include/Ice/StreamHelpers.h +1 -1
  44. data/dist/ice/cpp/include/Ice/StreamableTraits.h +2 -2
  45. data/dist/ice/cpp/include/Ice/StringConverter.h +2 -3
  46. data/dist/ice/cpp/include/Ice/StringUtil.h +2 -7
  47. data/dist/ice/cpp/include/Ice/UUID.h +1 -0
  48. data/dist/ice/cpp/include/Ice/Value.h +2 -2
  49. data/dist/ice/cpp/include/generated/Ice/BuiltinSequences.h +2 -2
  50. data/dist/ice/cpp/include/generated/Ice/Context.h +2 -2
  51. data/dist/ice/cpp/include/generated/Ice/EndpointTypes.h +2 -2
  52. data/dist/ice/cpp/include/generated/Ice/Identity.h +2 -2
  53. data/dist/ice/cpp/include/generated/Ice/Locator.h +50 -14
  54. data/dist/ice/cpp/include/generated/Ice/LocatorRegistry.h +38 -11
  55. data/dist/ice/cpp/include/generated/Ice/Metrics.h +94 -39
  56. data/dist/ice/cpp/include/generated/Ice/OperationMode.h +2 -2
  57. data/dist/ice/cpp/include/generated/Ice/Process.h +34 -8
  58. data/dist/ice/cpp/include/generated/Ice/PropertiesAdmin.h +42 -11
  59. data/dist/ice/cpp/include/generated/Ice/PropertyDict.h +2 -2
  60. data/dist/ice/cpp/include/generated/Ice/RemoteLogger.h +93 -40
  61. data/dist/ice/cpp/include/generated/Ice/ReplyStatus.h +2 -2
  62. data/dist/ice/cpp/include/generated/Ice/Router.h +50 -14
  63. data/dist/ice/cpp/include/generated/Ice/SliceChecksumDict.h +2 -2
  64. data/dist/ice/cpp/include/generated/Ice/Version.h +2 -2
  65. data/dist/ice/cpp/include/generated/IceDiscovery/Lookup.h +66 -14
  66. data/dist/ice/cpp/include/generated/IceLocatorDiscovery/Lookup.h +34 -8
  67. data/dist/ice/cpp/src/Ice/AddDefaultPluginFactories_all.cpp +1 -1
  68. data/dist/ice/cpp/src/Ice/Base64.cpp +47 -137
  69. data/dist/ice/cpp/src/Ice/Base64.h +2 -2
  70. data/dist/ice/cpp/src/Ice/BatchRequestQueue.cpp +28 -13
  71. data/dist/ice/cpp/src/Ice/BatchRequestQueue.h +5 -1
  72. data/dist/ice/cpp/src/Ice/Buffer.cpp +1 -1
  73. data/dist/ice/cpp/src/Ice/CollocatedRequestHandler.cpp +1 -1
  74. data/dist/ice/cpp/src/Ice/CollocatedRequestHandler.h +1 -1
  75. data/dist/ice/cpp/src/Ice/Communicator.cpp +4 -3
  76. data/dist/ice/cpp/src/Ice/CommunicatorFlushBatchAsync.cpp +8 -0
  77. data/dist/ice/cpp/src/Ice/ConnectRequestHandler.cpp +5 -15
  78. data/dist/ice/cpp/src/Ice/ConnectRequestHandler.h +1 -1
  79. data/dist/ice/cpp/src/Ice/ConnectionFactory.cpp +6 -8
  80. data/dist/ice/cpp/src/Ice/ConnectionFactory.h +0 -3
  81. data/dist/ice/cpp/src/Ice/ConnectionI.cpp +94 -99
  82. data/dist/ice/cpp/src/Ice/ConnectionI.h +11 -8
  83. data/dist/ice/cpp/src/Ice/ConsoleUtil.cpp +1 -1
  84. data/dist/ice/cpp/src/Ice/DefaultsAndOverrides.cpp +10 -14
  85. data/dist/ice/cpp/src/Ice/EndpointI.h +1 -1
  86. data/dist/ice/cpp/src/Ice/FileUtil.cpp +12 -12
  87. data/dist/ice/cpp/src/Ice/FixedRequestHandler.cpp +1 -1
  88. data/dist/ice/cpp/src/Ice/FixedRequestHandler.h +1 -1
  89. data/dist/ice/cpp/src/Ice/HttpParser.h +0 -2
  90. data/dist/ice/cpp/src/Ice/IdleTimeoutTransceiverDecorator.cpp +6 -3
  91. data/dist/ice/cpp/src/Ice/IncomingRequest.cpp +1 -3
  92. data/dist/ice/cpp/src/Ice/InputStream.cpp +23 -19
  93. data/dist/ice/cpp/src/Ice/Instance.cpp +73 -50
  94. data/dist/ice/cpp/src/Ice/Instance.h +1 -6
  95. data/dist/ice/cpp/src/Ice/LocalExceptions.cpp +1 -1
  96. data/dist/ice/cpp/src/Ice/LocatorInfo.cpp +2 -2
  97. data/dist/ice/cpp/src/Ice/LoggerAdminI.cpp +13 -18
  98. data/dist/ice/cpp/src/Ice/LoggerI.cpp +1 -1
  99. data/dist/ice/cpp/src/Ice/LoggerI.h +2 -2
  100. data/dist/ice/cpp/src/Ice/MetricsAdminI.h +6 -1
  101. data/dist/ice/cpp/src/Ice/MetricsObserverI.h +22 -18
  102. data/dist/ice/cpp/src/Ice/NativePropertiesAdmin.cpp +5 -2
  103. data/dist/ice/cpp/src/Ice/Network.cpp +168 -103
  104. data/dist/ice/cpp/src/Ice/Network.h +12 -7
  105. data/dist/ice/cpp/src/Ice/NetworkProxy.cpp +17 -6
  106. data/dist/ice/cpp/src/Ice/NetworkProxy.h +2 -1
  107. data/dist/ice/cpp/src/Ice/Object.cpp +1 -1
  108. data/dist/ice/cpp/src/Ice/ObjectAdapterI.cpp +56 -19
  109. data/dist/ice/cpp/src/Ice/OpaqueEndpointI.cpp +10 -10
  110. data/dist/ice/cpp/src/Ice/Options.cpp +7 -2
  111. data/dist/ice/cpp/src/Ice/OutgoingAsync.cpp +1 -1
  112. data/dist/ice/cpp/src/Ice/OutputStream.cpp +4 -4
  113. data/dist/ice/cpp/src/Ice/PluginManagerI.cpp +7 -1
  114. data/dist/ice/cpp/src/Ice/Properties.cpp +26 -16
  115. data/dist/ice/cpp/src/Ice/PropertyUtil.cpp +1 -1
  116. data/dist/ice/cpp/src/Ice/ProtocolInstance.cpp +0 -11
  117. data/dist/ice/cpp/src/Ice/ProtocolInstance.h +1 -2
  118. data/dist/ice/cpp/src/Ice/Proxy.cpp +9 -1
  119. data/dist/ice/cpp/src/Ice/ProxyAsync.cpp +110 -13
  120. data/dist/ice/cpp/src/Ice/Random.cpp +68 -7
  121. data/dist/ice/cpp/src/Ice/Random.h +6 -2
  122. data/dist/ice/cpp/src/Ice/Reference.cpp +22 -11
  123. data/dist/ice/cpp/src/Ice/Reference.h +3 -0
  124. data/dist/ice/cpp/src/Ice/ReferenceFactory.cpp +10 -0
  125. data/dist/ice/cpp/src/Ice/RequestHandler.h +3 -1
  126. data/dist/ice/cpp/src/Ice/RequestHandlerCache.cpp +1 -1
  127. data/dist/ice/cpp/src/Ice/RequestHandlerCache.h +1 -1
  128. data/dist/ice/cpp/src/Ice/ResourceConfig.h +3 -3
  129. data/dist/ice/cpp/src/Ice/RetryQueue.cpp +8 -12
  130. data/dist/ice/cpp/src/Ice/SHA1.cpp +11 -11
  131. data/dist/ice/cpp/src/Ice/SSL/DistinguishedName.cpp +0 -6
  132. data/dist/ice/cpp/src/Ice/SSL/DistinguishedName.h +0 -6
  133. data/dist/ice/cpp/src/Ice/SSL/OpenSSLEngine.cpp +15 -1
  134. data/dist/ice/cpp/src/Ice/SSL/OpenSSLTransceiverI.cpp +77 -27
  135. data/dist/ice/cpp/src/Ice/SSL/OpenSSLTransceiverI.h +2 -1
  136. data/dist/ice/cpp/src/Ice/SSL/RFC2253.cpp +2 -2
  137. data/dist/ice/cpp/src/Ice/SSL/SSLUtil.cpp +39 -34
  138. data/dist/ice/cpp/src/Ice/SSL/SchannelEngine.cpp +130 -52
  139. data/dist/ice/cpp/src/Ice/SSL/SchannelTransceiverI.cpp +64 -33
  140. data/dist/ice/cpp/src/Ice/SSL/SchannelTransceiverI.h +0 -1
  141. data/dist/ice/cpp/src/Ice/SSL/SecureTransportEngine.cpp +3 -3
  142. data/dist/ice/cpp/src/Ice/SSL/SecureTransportTransceiverI.cpp +9 -3
  143. data/dist/ice/cpp/src/Ice/SSL/SecureTransportUtil.cpp +73 -51
  144. data/dist/ice/cpp/src/Ice/SSL/SecureTransportUtil.h +0 -8
  145. data/dist/ice/cpp/src/Ice/Selector.cpp +13 -11
  146. data/dist/ice/cpp/src/Ice/ServantManager.cpp +3 -3
  147. data/dist/ice/cpp/src/Ice/Service.cpp +33 -115
  148. data/dist/ice/cpp/src/Ice/StreamSocket.cpp +33 -40
  149. data/dist/ice/cpp/src/Ice/StreamSocket.h +4 -4
  150. data/dist/ice/cpp/src/Ice/StringConverter.cpp +1 -1
  151. data/dist/ice/cpp/src/Ice/StringUtil.cpp +12 -21
  152. data/dist/ice/cpp/src/Ice/SysLoggerI.cpp +136 -100
  153. data/dist/ice/cpp/src/Ice/SysLoggerI.h +7 -3
  154. data/dist/ice/cpp/src/Ice/SystemdJournalI.cpp +1 -1
  155. data/dist/ice/cpp/src/Ice/TcpAcceptor.cpp +7 -7
  156. data/dist/ice/cpp/src/Ice/TcpAcceptor.h +2 -1
  157. data/dist/ice/cpp/src/Ice/TcpBufSize.h +40 -0
  158. data/dist/ice/cpp/src/Ice/TcpConnector.cpp +5 -2
  159. data/dist/ice/cpp/src/Ice/TcpConnector.h +2 -0
  160. data/dist/ice/cpp/src/Ice/TcpTransceiver.cpp +6 -2
  161. data/dist/ice/cpp/src/Ice/ThreadPool.cpp +2 -8
  162. data/dist/ice/cpp/src/Ice/ThreadPool.h +0 -2
  163. data/dist/ice/cpp/src/Ice/Timer.cpp +7 -3
  164. data/dist/ice/cpp/src/Ice/UUID.cpp +1 -2
  165. data/dist/ice/cpp/src/Ice/UdpEndpointI.cpp +4 -1
  166. data/dist/ice/cpp/src/Ice/UdpTransceiver.cpp +136 -123
  167. data/dist/ice/cpp/src/Ice/UdpTransceiver.h +3 -4
  168. data/dist/ice/cpp/src/Ice/WSTransceiver.cpp +96 -27
  169. data/dist/ice/cpp/src/Ice/WSTransceiver.h +1 -1
  170. data/dist/ice/cpp/src/Ice/generated/BuiltinSequences.cpp +2 -2
  171. data/dist/ice/cpp/src/Ice/generated/Context.cpp +2 -2
  172. data/dist/ice/cpp/src/Ice/generated/EndpointTypes.cpp +2 -2
  173. data/dist/ice/cpp/src/Ice/generated/Identity.cpp +2 -2
  174. data/dist/ice/cpp/src/Ice/generated/Locator.cpp +2 -2
  175. data/dist/ice/cpp/src/Ice/generated/LocatorRegistry.cpp +2 -2
  176. data/dist/ice/cpp/src/Ice/generated/Metrics.cpp +2 -2
  177. data/dist/ice/cpp/src/Ice/generated/OperationMode.cpp +2 -2
  178. data/dist/ice/cpp/src/Ice/generated/Process.cpp +2 -2
  179. data/dist/ice/cpp/src/Ice/generated/PropertiesAdmin.cpp +2 -2
  180. data/dist/ice/cpp/src/Ice/generated/PropertyDict.cpp +2 -2
  181. data/dist/ice/cpp/src/Ice/generated/RemoteLogger.cpp +2 -2
  182. data/dist/ice/cpp/src/Ice/generated/ReplyStatus.cpp +2 -2
  183. data/dist/ice/cpp/src/Ice/generated/Router.cpp +2 -2
  184. data/dist/ice/cpp/src/Ice/generated/SliceChecksumDict.cpp +2 -2
  185. data/dist/ice/cpp/src/Ice/generated/Version.cpp +2 -2
  186. data/dist/ice/cpp/src/IceDiscovery/LookupI.cpp +47 -9
  187. data/dist/ice/cpp/src/IceDiscovery/LookupI.h +8 -3
  188. data/dist/ice/cpp/src/IceDiscovery/generated/Lookup.cpp +2 -2
  189. data/dist/ice/cpp/src/IceLocatorDiscovery/PluginI.cpp +43 -14
  190. data/dist/ice/cpp/src/IceLocatorDiscovery/generated/Lookup.cpp +2 -2
  191. data/dist/ice/cpp/src/Slice/DocCommentParser.cpp +26 -20
  192. data/dist/ice/cpp/src/Slice/DocCommentParser.h +2 -2
  193. data/dist/ice/cpp/src/Slice/FileTracker.cpp +3 -11
  194. data/dist/ice/cpp/src/Slice/FileTracker.h +0 -2
  195. data/dist/ice/cpp/src/Slice/Grammar.cpp +211 -210
  196. data/dist/ice/cpp/src/Slice/MetadataValidation.cpp +10 -9
  197. data/dist/ice/cpp/src/Slice/Parser.cpp +28 -20
  198. data/dist/ice/cpp/src/Slice/Parser.h +3 -4
  199. data/dist/ice/cpp/src/Slice/Preprocessor.cpp +3 -11
  200. data/dist/ice/cpp/src/Slice/Preprocessor.h +0 -2
  201. data/dist/ice/cpp/src/Slice/Scanner.cpp +3 -3
  202. data/dist/ice/cpp/src/Slice/SliceUtil.cpp +197 -114
  203. data/dist/ice/cpp/src/Slice/StringLiteralUtil.cpp +0 -2
  204. data/dist/ice/cpp/src/Slice/Util.h +21 -9
  205. data/dist/ice/cpp/src/slice2rb/Ruby.cpp +7 -3
  206. data/dist/ice/cpp/src/slice2rb/RubyUtil.cpp +16 -12
  207. data/dist/ice/cpp/src/slice2rb/RubyUtil.h +3 -3
  208. data/dist/ice/slice/Glacier2/Router.ice +3 -3
  209. data/dist/ice/slice/Ice/Metrics.ice +6 -5
  210. data/dist/ice/slice/Ice/RemoteLogger.ice +5 -5
  211. data/dist/ice/slice/IceGrid/Admin.ice +9 -9
  212. data/dist/ice/slice/IceGrid/Descriptor.ice +5 -5
  213. data/dist/ice/slice/IceStorm/Metrics.ice +1 -1
  214. data/dist/lib/Glacier2/Metrics.rb +1 -1
  215. data/dist/lib/Glacier2/PermissionsVerifier.rb +1 -1
  216. data/dist/lib/Glacier2/Router.rb +2 -2
  217. data/dist/lib/Glacier2/SSLInfo.rb +1 -1
  218. data/dist/lib/Glacier2/Session.rb +1 -1
  219. data/dist/lib/Ice/BuiltinSequences.rb +1 -1
  220. data/dist/lib/Ice/CompressBatch.rb +1 -2
  221. data/dist/lib/Ice/Context.rb +1 -1
  222. data/dist/lib/Ice/EndpointSelectionType.rb +1 -2
  223. data/dist/lib/Ice/EndpointTypes.rb +1 -1
  224. data/dist/lib/Ice/Identity.rb +1 -1
  225. data/dist/lib/Ice/IdentitySpaceship.rb +1 -0
  226. data/dist/lib/Ice/Locator.rb +1 -1
  227. data/dist/lib/Ice/LocatorRegistry.rb +1 -1
  228. data/dist/lib/Ice/Metrics.rb +1 -1
  229. data/dist/lib/Ice/OperationMode.rb +2 -3
  230. data/dist/lib/Ice/Process.rb +1 -1
  231. data/dist/lib/Ice/PropertiesAdmin.rb +1 -1
  232. data/dist/lib/Ice/PropertyDict.rb +1 -1
  233. data/dist/lib/Ice/RemoteLogger.rb +2 -3
  234. data/dist/lib/Ice/ReplyStatus.rb +2 -3
  235. data/dist/lib/Ice/Router.rb +1 -1
  236. data/dist/lib/Ice/SliceChecksumDict.rb +1 -1
  237. data/dist/lib/Ice/SliceUtil.rb +2 -2
  238. data/dist/lib/Ice/Struct.rb +1 -0
  239. data/dist/lib/Ice/ToStringMode.rb +1 -2
  240. data/dist/lib/Ice/Value.rb +2 -2
  241. data/dist/lib/Ice/Version.rb +1 -1
  242. data/dist/lib/IceBox/ServiceManager.rb +1 -1
  243. data/dist/lib/IceGrid/Admin.rb +3 -4
  244. data/dist/lib/IceGrid/Descriptor.rb +1 -1
  245. data/dist/lib/IceGrid/Exception.rb +1 -1
  246. data/dist/lib/IceGrid/FileParser.rb +1 -1
  247. data/dist/lib/IceGrid/Registry.rb +2 -3
  248. data/dist/lib/IceGrid/Session.rb +2 -2
  249. data/dist/lib/IceGrid/UserAccountMapper.rb +1 -1
  250. data/dist/lib/IceStorm/IceStorm.rb +1 -1
  251. data/dist/lib/IceStorm/Metrics.rb +1 -1
  252. data/extconf.rb +1 -1
  253. data/ice.gemspec +3 -3
  254. metadata +4 -5
  255. data/dist/ice/cpp/src/Ice/DLLMain.cpp +0 -40
  256. data/dist/ice/cpp/src/Ice/UndefSysMacros.h +0 -37
@@ -83,6 +83,7 @@ OpenSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::
83
83
  _sslCtx = _localSSLContextSelectionCallback(_incoming ? _adapterName : _host);
84
84
  if (!_sslCtx)
85
85
  {
86
+ BIO_free(bio);
86
87
  throw SecurityException(__FILE__, __LINE__, "SSL error: the SSL context selection callback returned null");
87
88
  }
88
89
  _ssl = SSL_new(_sslCtx);
@@ -123,7 +124,8 @@ OpenSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::
123
124
 
124
125
  if (ret <= 0)
125
126
  {
126
- switch (SSL_get_error(_ssl, ret))
127
+ int sslError = SSL_get_error(_ssl, ret);
128
+ switch (sslError)
127
129
  {
128
130
  case SSL_ERROR_NONE:
129
131
  {
@@ -163,7 +165,9 @@ OpenSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::
163
165
  break;
164
166
  }
165
167
 
166
- if (IceInternal::connectionLost() || IceInternal::getSocketErrno() == 0)
168
+ // A handshake I/O failure after the delegate lost its fd is a connection loss.
169
+ if (_delegate->getNativeInfo()->fd() == INVALID_SOCKET || IceInternal::connectionLost() ||
170
+ IceInternal::getSocketErrno() == 0)
167
171
  {
168
172
  throw ConnectionLostException(__FILE__, __LINE__, IceInternal::getSocketErrno());
169
173
  }
@@ -191,6 +195,18 @@ OpenSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::
191
195
  }
192
196
  #endif
193
197
  }
198
+ default:
199
+ {
200
+ // Any other result (e.g. SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_WANT_ASYNC or
201
+ // SSL_ERROR_WANT_RETRY_VERIFY, reachable with a user-supplied SSL_CTX) is not driven by
202
+ // this event loop. Throw instead of falling through and busy-spinning on the while loop.
203
+ ostringstream os;
204
+ os << "SSL error occurred for new " << (_incoming ? "incoming" : "outgoing") << " connection:\n"
205
+ << _delegate->toString() << "\n"
206
+ << "SSL_get_error returned " << sslError << " (ret=" << ret << ")\n"
207
+ << _engine->sslErrors();
208
+ throw ProtocolException(__FILE__, __LINE__, os.str());
209
+ }
194
210
  }
195
211
  }
196
212
  }
@@ -200,7 +216,7 @@ OpenSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::
200
216
  rethrow_exception(_verificationException);
201
217
  }
202
218
 
203
- // Retrieve the certificate chain if the verification callback has not already fill it.
219
+ // Retrieve the certificate chain if the verification callback has not already filled it.
204
220
  if (!_peerCertificate)
205
221
  {
206
222
  // When calling on the server side the peer certificate is not included in SSL_get_peer_cert_chain and must be
@@ -224,6 +240,12 @@ OpenSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::
224
240
  }
225
241
  }
226
242
 
243
+ if (!_peerCertificate)
244
+ {
245
+ _engine->verifyPeer(dynamic_pointer_cast<ConnectionInfo>(getInfo(_incoming, _adapterName, "")));
246
+ }
247
+ // else verifyPeer is called from the configured OpenSSL verify callback.
248
+
227
249
  if (_engine->securityTraceLevel() >= 1)
228
250
  {
229
251
  Trace out(_instance->logger(), _engine->securityTraceCategory());
@@ -259,14 +281,19 @@ OpenSSL::TransceiverI::close()
259
281
  {
260
282
  if (_ssl)
261
283
  {
262
- int err = SSL_shutdown(_ssl);
263
-
264
- //
265
- // Call it one more time if it returned 0.
266
- //
267
- if (err == 0)
284
+ // The socket BIO installed in _ssl during initialization caches the fd number. Skip the shutdown
285
+ // notification when the delegate no longer holds this fd.
286
+ if (_delegate->getNativeInfo()->fd() != INVALID_SOCKET)
268
287
  {
269
- SSL_shutdown(_ssl);
288
+ int err = SSL_shutdown(_ssl);
289
+
290
+ //
291
+ // Call it one more time if it returned 0.
292
+ //
293
+ if (err == 0)
294
+ {
295
+ SSL_shutdown(_ssl);
296
+ }
270
297
  }
271
298
 
272
299
  SSL_free(_ssl);
@@ -301,6 +328,12 @@ OpenSSL::TransceiverI::write(IceInternal::Buffer& buf)
301
328
  return IceInternal::SocketOperationNone;
302
329
  }
303
330
 
331
+ // The socket BIO installed in _ssl caches the fd number; fail instead of letting OpenSSL use a stale number.
332
+ if (_delegate->getNativeInfo()->fd() == INVALID_SOCKET)
333
+ {
334
+ throw ConnectionLostException(__FILE__, __LINE__);
335
+ }
336
+
304
337
  //
305
338
  // It's impossible for packetSize to be more than an Int.
306
339
  //
@@ -337,12 +370,6 @@ OpenSSL::TransceiverI::write(IceInternal::Buffer& buf)
337
370
  continue;
338
371
  }
339
372
 
340
- if (IceInternal::noBuffers() && packetSize > 1024)
341
- {
342
- packetSize /= 2;
343
- continue;
344
- }
345
-
346
373
  if (IceInternal::wouldBlock())
347
374
  {
348
375
  assert(SSL_want_write(_ssl));
@@ -393,6 +420,12 @@ OpenSSL::TransceiverI::read(IceInternal::Buffer& buf)
393
420
  return IceInternal::SocketOperationNone;
394
421
  }
395
422
 
423
+ // The socket BIO installed in _ssl caches the fd number; fail instead of letting OpenSSL use a stale number.
424
+ if (_delegate->getNativeInfo()->fd() == INVALID_SOCKET)
425
+ {
426
+ throw ConnectionLostException(__FILE__, __LINE__);
427
+ }
428
+
396
429
  _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead, false);
397
430
 
398
431
  // It's impossible for packetSize to be more than an Int.
@@ -430,12 +463,6 @@ OpenSSL::TransceiverI::read(IceInternal::Buffer& buf)
430
463
  continue;
431
464
  }
432
465
 
433
- if (IceInternal::noBuffers() && packetSize > 1024)
434
- {
435
- packetSize /= 2;
436
- continue;
437
- }
438
-
439
466
  if (IceInternal::wouldBlock())
440
467
  {
441
468
  assert(SSL_want_read(_ssl));
@@ -514,15 +541,15 @@ OpenSSL::TransceiverI::getInfo(bool incoming, string adapterName, string connect
514
541
  // adapterName is the name of the object adapter currently associated with this connection, while _adapterName
515
542
  // represents the name of the object adapter that created this connection (incoming only).
516
543
 
544
+ Ice::ConnectionInfoPtr delegateInfo = _delegate->getInfo(incoming, std::move(adapterName), std::move(connectionId));
545
+
517
546
  X509* peerCertificate = nullptr;
518
547
  if (_peerCertificate)
519
548
  {
520
549
  peerCertificate = X509_dup(_peerCertificate);
521
550
  }
522
551
 
523
- return make_shared<ConnectionInfo>(
524
- _delegate->getInfo(incoming, std::move(adapterName), std::move(connectionId)),
525
- peerCertificate);
552
+ return make_shared<ConnectionInfo>(std::move(delegateInfo), peerCertificate);
526
553
  }
527
554
 
528
555
  void
@@ -533,7 +560,27 @@ OpenSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&)
533
560
  void
534
561
  OpenSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize)
535
562
  {
536
- _delegate->setBufferSize(rcvSize, sndSize);
563
+ try
564
+ {
565
+ _delegate->setBufferSize(rcvSize, sndSize);
566
+ }
567
+ catch (...)
568
+ {
569
+ invalidateBIOFd();
570
+ throw;
571
+ }
572
+ }
573
+
574
+ void
575
+ OpenSSL::TransceiverI::invalidateBIOFd() const
576
+ {
577
+ if (_ssl && _delegate->getNativeInfo()->fd() == INVALID_SOCKET)
578
+ {
579
+ // The socket BIO installed in _ssl caches the fd number. The delegate no longer holds this fd, so invalidate
580
+ // the BIO's copy: later TLS I/O — including handshake records written from inside SSL_accept/SSL_connect —
581
+ // fails with EBADF instead of touching a reused descriptor.
582
+ BIO_set_fd(SSL_get_wbio(_ssl), INVALID_SOCKET, BIO_NOCLOSE);
583
+ }
537
584
  }
538
585
 
539
586
  int
@@ -558,7 +605,10 @@ OpenSSL::TransceiverI::verifyCallback(int ok, X509_STORE_CTX* ctx)
558
605
  dynamic_pointer_cast<ConnectionInfo>(getInfo(_incoming, _adapterName, "")));
559
606
  if (!verified)
560
607
  {
561
- long result = SSL_get_verify_result(_ssl);
608
+ // Read the failure reason from the current verification context rather than from
609
+ // SSL_get_verify_result(_ssl), which is only finalized at the end of chain verification and is
610
+ // stale/generic inside this per-certificate callback.
611
+ int result = X509_STORE_CTX_get_error(ctx);
562
612
  if (result == X509_V_OK)
563
613
  {
564
614
  throw SecurityException(
@@ -55,6 +55,8 @@ namespace Ice::SSL::OpenSSL
55
55
  private:
56
56
  friend class Ice::SSL::OpenSSL::SSLEngine;
57
57
 
58
+ void invalidateBIOFd() const;
59
+
58
60
  const InstancePtr _instance;
59
61
  const Ice::SSL::OpenSSL::SSLEnginePtr _engine;
60
62
  const std::string _host;
@@ -62,7 +64,6 @@ namespace Ice::SSL::OpenSSL
62
64
  const bool _incoming;
63
65
  const IceInternal::TransceiverPtr _delegate;
64
66
  bool _connected;
65
- std::string _cipher;
66
67
  X509* _peerCertificate;
67
68
  ::SSL* _ssl;
68
69
  SSL_CTX* _sslCtx;
@@ -242,7 +242,7 @@ parseAttributeType(const string& data, size_t& pos)
242
242
  eatWhite(data, pos);
243
243
  if (pos >= data.size())
244
244
  {
245
- throw Ice::ParseException(__FILE__, __LINE__, "invalid attribute type (expected end of data)");
245
+ throw Ice::ParseException(__FILE__, __LINE__, "invalid attribute type (unexpected end of data)");
246
246
  }
247
247
 
248
248
  string result;
@@ -290,7 +290,7 @@ parseAttributeType(const string& data, size_t& pos)
290
290
  // 1*DIGIT must follow "."
291
291
  if (pos < data.size() && !IceInternal::isDigit(data[pos]))
292
292
  {
293
- throw Ice::ParseException(__FILE__, __LINE__, "invalid attribute type (expected end of data)");
293
+ throw Ice::ParseException(__FILE__, __LINE__, "invalid attribute type (missing digit after '.')");
294
294
  }
295
295
  }
296
296
  else
@@ -6,7 +6,6 @@
6
6
  #define OPENSSL_NO_DEPRECATED
7
7
 
8
8
  #include "SSLUtil.h"
9
- #include "../Base64.h"
10
9
  #include "../FileUtil.h"
11
10
  #include "../Network.h"
12
11
  #include "../UniqueRef.h"
@@ -35,8 +34,8 @@ Ice::SSL::fromCFString(CFStringRef v)
35
34
  CFIndex size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(v), kCFStringEncodingUTF8);
36
35
  vector<char> buffer;
37
36
  buffer.resize(static_cast<size_t>(size + 1));
38
- CFStringGetCString(v, &buffer[0], static_cast<CFIndex>(buffer.size()), kCFStringEncodingUTF8);
39
- s.assign(&buffer[0]);
37
+ CFStringGetCString(v, buffer.data(), static_cast<CFIndex>(buffer.size()), kCFStringEncodingUTF8);
38
+ s.assign(buffer.data());
40
39
  }
41
40
  return s;
42
41
  }
@@ -102,7 +101,7 @@ Ice::SSL::readFile(const string& file, vector<char>& buffer)
102
101
 
103
102
  if (!buffer.empty())
104
103
  {
105
- is.read(&buffer[0], static_cast<streamsize>(buffer.size()));
104
+ is.read(buffer.data(), static_cast<streamsize>(buffer.size()));
106
105
  if (!is.good())
107
106
  {
108
107
  throw CertificateReadException(__FILE__, __LINE__, "error reading file " + file);
@@ -251,13 +250,13 @@ namespace
251
250
  X509_ASN_ENCODING,
252
251
  certName,
253
252
  CERT_OID_NAME_STR | CERT_NAME_STR_REVERSE_FLAG,
254
- &buffer[0],
253
+ buffer.data(),
255
254
  length))
256
255
  {
257
256
  throw CertificateEncodingException(__FILE__, __LINE__, IceInternal::lastErrorToString());
258
257
  }
259
258
 
260
- string s(&buffer[0]);
259
+ string s(buffer.data());
261
260
  for (const auto& certificateOID : certificateOIDS)
262
261
  {
263
262
  const string name = string(certificateOID.first) + "=";
@@ -396,12 +395,12 @@ Ice::SSL::encodeCertificate(PCCERT_CONTEXT cert)
396
395
  cert->pbCertEncoded,
397
396
  cert->cbCertEncoded,
398
397
  CRYPT_STRING_BASE64HEADER | CRYPT_STRING_NOCR,
399
- &encoded[0],
398
+ encoded.data(),
400
399
  &encodedLength))
401
400
  {
402
401
  throw CertificateEncodingException(__FILE__, __LINE__, IceInternal::lastErrorToString());
403
402
  }
404
- s.assign(&encoded[0]);
403
+ s.assign(encoded.data());
405
404
  return s;
406
405
  }
407
406
 
@@ -414,10 +413,10 @@ Ice::SSL::decodeCertificate(const string& data)
414
413
  derBuffer.resize(derLength);
415
414
 
416
415
  if (!CryptStringToBinary(
417
- &data.c_str()[0],
416
+ data.c_str(),
418
417
  static_cast<DWORD>(data.size()),
419
418
  CRYPT_STRING_BASE64HEADER,
420
- &derBuffer[0],
419
+ derBuffer.data(),
421
420
  &derLength,
422
421
  nullptr,
423
422
  nullptr))
@@ -431,7 +430,7 @@ Ice::SSL::decodeCertificate(const string& data)
431
430
  if (!CryptDecodeObjectEx(
432
431
  X509_ASN_ENCODING,
433
432
  X509_CERT,
434
- &derBuffer[0],
433
+ derBuffer.data(),
435
434
  derLength,
436
435
  CRYPT_DECODE_ALLOC_FLAG,
437
436
  nullptr,
@@ -496,6 +495,19 @@ namespace
496
495
  return result;
497
496
  }
498
497
 
498
+ string convertIA5StringToString(ASN1_IA5STRING* str)
499
+ {
500
+ if (str && ASN1_STRING_type(str) == V_ASN1_IA5STRING && ASN1_STRING_length(str) > 0)
501
+ {
502
+ const unsigned char* data = ASN1_STRING_get0_data(str);
503
+ if (data)
504
+ {
505
+ return {reinterpret_cast<const char*>(data), static_cast<size_t>(ASN1_STRING_length(str))};
506
+ }
507
+ }
508
+ return {};
509
+ }
510
+
499
511
  vector<pair<int, string>> convertGeneralNames(GENERAL_NAMES* gens)
500
512
  {
501
513
  vector<pair<int, string>> alt;
@@ -512,20 +524,12 @@ namespace
512
524
  {
513
525
  case GEN_EMAIL:
514
526
  {
515
- ASN1_IA5STRING* str = gen->d.rfc822Name;
516
- if (str && str->type == V_ASN1_IA5STRING && str->data && str->length > 0)
517
- {
518
- p.second = string(reinterpret_cast<const char*>(str->data), str->length);
519
- }
527
+ p.second = convertIA5StringToString(gen->d.rfc822Name);
520
528
  break;
521
529
  }
522
530
  case GEN_DNS:
523
531
  {
524
- ASN1_IA5STRING* str = gen->d.dNSName;
525
- if (str && str->type == V_ASN1_IA5STRING && str->data && str->length > 0)
526
- {
527
- p.second = string(reinterpret_cast<const char*>(str->data), str->length);
528
- }
532
+ p.second = convertIA5StringToString(gen->d.dNSName);
529
533
  break;
530
534
  }
531
535
  case GEN_DIRNAME:
@@ -535,29 +539,29 @@ namespace
535
539
  }
536
540
  case GEN_URI:
537
541
  {
538
- ASN1_IA5STRING* str = gen->d.uniformResourceIdentifier;
539
- if (str && str->type == V_ASN1_IA5STRING && str->data && str->length > 0)
540
- {
541
- p.second = string(reinterpret_cast<const char*>(str->data), str->length);
542
- }
542
+ p.second = convertIA5StringToString(gen->d.uniformResourceIdentifier);
543
543
  break;
544
544
  }
545
545
  case GEN_IPADD:
546
546
  {
547
547
  ASN1_OCTET_STRING* addr = gen->d.iPAddress;
548
548
  // TODO: Support IPv6 someday.
549
- if (addr && addr->type == V_ASN1_OCTET_STRING && addr->data && addr->length == 4)
549
+ if (addr && ASN1_STRING_type(addr) == V_ASN1_OCTET_STRING && ASN1_STRING_length(addr) == 4)
550
550
  {
551
- ostringstream ostr;
552
- for (int j = 0; j < 4; ++j)
551
+ const unsigned char* data = ASN1_STRING_get0_data(addr);
552
+ if (data)
553
553
  {
554
- if (j > 0)
554
+ ostringstream ostr;
555
+ for (int j = 0; j < 4; ++j)
555
556
  {
556
- ostr << '.';
557
+ if (j > 0)
558
+ {
559
+ ostr << '.';
560
+ }
561
+ ostr << static_cast<int>(data[j]);
557
562
  }
558
- ostr << static_cast<int>(addr->data[j]);
563
+ p.second = ostr.str();
559
564
  }
560
- p.second = ostr.str();
561
565
  }
562
566
  break;
563
567
  }
@@ -656,7 +660,7 @@ Ice::SSL::encodeCertificate(X509* certificate)
656
660
  X509*
657
661
  Ice::SSL::decodeCertificate(const string& data)
658
662
  {
659
- BIO* cert = BIO_new_mem_buf(static_cast<void*>(const_cast<char*>(&data[0])), static_cast<int>(data.size()));
663
+ BIO* cert = BIO_new_mem_buf(static_cast<void*>(const_cast<char*>(data.data())), static_cast<int>(data.size()));
660
664
  x509_st* x = PEM_read_bio_X509(cert, nullptr, nullptr, nullptr);
661
665
  BIO_free(cert);
662
666
  if (x == nullptr)
@@ -666,6 +670,7 @@ Ice::SSL::decodeCertificate(const string& data)
666
670
  // Calling it with -1 for the side effects, this ensure that the extensions info is loaded
667
671
  if (X509_check_purpose(x, -1, -1) == -1)
668
672
  {
673
+ X509_free(x);
669
674
  throw CertificateReadException(__FILE__, __LINE__, "error loading certificate:\n" + getErrors());
670
675
  }
671
676
  return x;