Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomNetworking/DicomAssociation.cpp @ 4432:fcbac3e8ac1c
dicom tls for scu
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 04 Jan 2021 15:59:32 +0100 |
parents | 5b254bd435d3 |
children | 4f92f2b3a3ae |
comparison
equal
deleted
inserted
replaced
4431:b7f27b116685 | 4432:fcbac3e8ac1c |
---|---|
114 } | 114 } |
115 | 115 |
116 | 116 |
117 void DicomAssociation::CloseInternal() | 117 void DicomAssociation::CloseInternal() |
118 { | 118 { |
119 #if ORTHANC_ENABLE_SSL == 1 | |
120 tls_.reset(NULL); // Transport layer must be destroyed before the association itself | |
121 #endif | |
122 | |
119 if (assoc_ != NULL) | 123 if (assoc_ != NULL) |
120 { | 124 { |
121 ASC_releaseAssociation(assoc_); | 125 ASC_releaseAssociation(assoc_); |
122 ASC_destroyAssociation(&assoc_); | 126 ASC_destroyAssociation(&assoc_); |
123 assoc_ = NULL; | 127 assoc_ = NULL; |
247 throw OrthancException(ErrorCode_ParameterOutOfRange); | 251 throw OrthancException(ErrorCode_ParameterOutOfRange); |
248 } | 252 } |
249 | 253 |
250 assert(net_ == NULL && | 254 assert(net_ == NULL && |
251 params_ == NULL && | 255 params_ == NULL && |
252 assoc_ == NULL); | 256 assoc_ == NULL && |
257 tls_.get() == NULL); | |
253 | 258 |
254 if (proposed_.empty()) | 259 if (proposed_.empty()) |
255 { | 260 { |
256 throw OrthancException(ErrorCode_BadSequenceOfCalls, | 261 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
257 "No presentation context was proposed"); | 262 "No presentation context was proposed"); |
264 << ":" << parameters.GetRemoteModality().GetPortNumber() | 269 << ":" << parameters.GetRemoteModality().GetPortNumber() |
265 << " (manufacturer: " << EnumerationToString(parameters.GetRemoteModality().GetManufacturer()) << ")"; | 270 << " (manufacturer: " << EnumerationToString(parameters.GetRemoteModality().GetManufacturer()) << ")"; |
266 | 271 |
267 CheckConnecting(parameters, ASC_initializeNetwork(NET_REQUESTOR, 0, /*opt_acse_timeout*/ acseTimeout, &net_)); | 272 CheckConnecting(parameters, ASC_initializeNetwork(NET_REQUESTOR, 0, /*opt_acse_timeout*/ acseTimeout, &net_)); |
268 CheckConnecting(parameters, ASC_createAssociationParameters(¶ms_, /*opt_maxReceivePDULength*/ ASC_DEFAULTMAXPDU)); | 273 CheckConnecting(parameters, ASC_createAssociationParameters(¶ms_, /*opt_maxReceivePDULength*/ ASC_DEFAULTMAXPDU)); |
274 | |
275 #if ORTHANC_ENABLE_SSL == 1 | |
276 if (false) // TODO - Configuration option | |
277 { | |
278 try | |
279 { | |
280 assert(net_ != NULL && | |
281 params_ != NULL); | |
282 | |
283 // TODO - Configuration options | |
284 tls_.reset(Internals::InitializeDicomTls(net_, NET_REQUESTOR, | |
285 "/tmp/j/Client.key", "/tmp/j/Client.crt", "/tmp/j/Server.crt")); | |
286 } | |
287 catch (OrthancException&) | |
288 { | |
289 CloseInternal(); | |
290 throw; | |
291 } | |
292 } | |
293 #endif | |
269 | 294 |
270 // Set this application's title and the called application's title in the params | 295 // Set this application's title and the called application's title in the params |
271 CheckConnecting(parameters, ASC_setAPTitles( | 296 CheckConnecting(parameters, ASC_setAPTitles( |
272 params_, parameters.GetLocalApplicationEntityTitle().c_str(), | 297 params_, parameters.GetLocalApplicationEntityTitle().c_str(), |
273 parameters.GetRemoteModality().GetApplicationEntityTitle().c_str(), NULL)); | 298 parameters.GetRemoteModality().GetApplicationEntityTitle().c_str(), NULL)); |
288 parameters.GetRemoteModality().GetPortNumber()); | 313 parameters.GetRemoteModality().GetPortNumber()); |
289 | 314 |
290 CheckConnecting(parameters, ASC_setPresentationAddresses(params_, localHost, remoteHostAndPort)); | 315 CheckConnecting(parameters, ASC_setPresentationAddresses(params_, localHost, remoteHostAndPort)); |
291 | 316 |
292 // Set various options | 317 // Set various options |
293 CheckConnecting(parameters, ASC_setTransportLayerType(params_, /*opt_secureConnection*/ false)); | 318 CheckConnecting(parameters, ASC_setTransportLayerType(params_, (tls_.get() != NULL) /*opt_secureConnection*/)); |
294 | 319 |
295 // Setup the list of proposed presentation contexts | 320 // Setup the list of proposed presentation contexts |
296 unsigned int presentationContextId = 1; | 321 unsigned int presentationContextId = 1; |
297 for (size_t i = 0; i < proposed_.size(); i++) | 322 for (size_t i = 0; i < proposed_.size(); i++) |
298 { | 323 { |