Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomNetworking/Internals/DicomTls.cpp @ 5644:343149762476
fix build with DCMTK <= 3.6.6
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 31 May 2024 18:23:44 +0200 |
parents | b1a18218860c |
children |
comparison
equal
deleted
inserted
replaced
5643:b1a18218860c | 5644:343149762476 |
---|---|
59 return (status != TCS_ok); | 59 return (status != TCS_ok); |
60 } | 60 } |
61 #endif | 61 #endif |
62 | 62 |
63 | 63 |
64 #if DCMTK_VERSION_NUMBER >= 367 | |
65 static OFCondition MyConvertOpenSSLError(unsigned long errorCode, OFBool logAsError) | |
66 { | |
67 return DcmTLSTransportLayer::convertOpenSSLError(errorCode, logAsError); | |
68 } | |
69 #else | |
70 static OFCondition MyConvertOpenSSLError(unsigned long errorCode, OFBool logAsError) | |
71 { | |
72 if (errorCode == 0) | |
73 { | |
74 return EC_Normal; | |
75 } | |
76 else | |
77 { | |
78 const char *err = ERR_reason_error_string(errorCode); | |
79 if (err == NULL) | |
80 { | |
81 err = "OpenSSL error"; | |
82 } | |
83 | |
84 if (logAsError) | |
85 { | |
86 DCMTLS_ERROR("OpenSSL error " << STD_NAMESPACE hex << STD_NAMESPACE setfill('0') | |
87 << STD_NAMESPACE setw(8) << errorCode << ": " << err); | |
88 } | |
89 | |
90 // The "2" below corresponds to the same error code as "DCMTLS_EC_FailedToSetCiphersuites" | |
91 return OFCondition(OFM_dcmtls, 2, OF_error, err); | |
92 } | |
93 } | |
94 #endif | |
95 | |
96 | |
64 DcmTLSTransportLayer* InitializeDicomTls(T_ASC_Network *network, | 97 DcmTLSTransportLayer* InitializeDicomTls(T_ASC_Network *network, |
65 T_ASC_NetworkRole role, | 98 T_ASC_NetworkRole role, |
66 const std::string& ownPrivateKeyPath, | 99 const std::string& ownPrivateKeyPath, |
67 const std::string& ownCertificatePath, | 100 const std::string& ownCertificatePath, |
68 const std::string& trustedCertificatesPath, | 101 const std::string& trustedCertificatesPath, |
237 Toolbox::JoinStrings(joinedCiphersTls, ciphersTls, ":"); | 270 Toolbox::JoinStrings(joinedCiphersTls, ciphersTls, ":"); |
238 Toolbox::JoinStrings(joinedCiphersTls13, ciphersTls13, ":"); | 271 Toolbox::JoinStrings(joinedCiphersTls13, ciphersTls13, ":"); |
239 | 272 |
240 if (joinedCiphersTls.size() > 0 && SSL_CTX_set_cipher_list(sslNativeHandle, joinedCiphersTls.c_str()) != 1) | 273 if (joinedCiphersTls.size() > 0 && SSL_CTX_set_cipher_list(sslNativeHandle, joinedCiphersTls.c_str()) != 1) |
241 { | 274 { |
242 OFCondition cond = DcmTLSTransportLayer::convertOpenSSLError(ERR_get_error(), OFTrue); | 275 OFCondition cond = MyConvertOpenSSLError(ERR_get_error(), OFTrue); |
243 throw OrthancException(ErrorCode_InternalError, "Unable to configure cipher suite. OpenSSL error: " + boost::lexical_cast<std::string>(cond.code()) + " - " + cond.text()); | 276 throw OrthancException(ErrorCode_InternalError, "Unable to configure cipher suite. OpenSSL error: " + boost::lexical_cast<std::string>(cond.code()) + " - " + cond.text()); |
244 } | 277 } |
245 | 278 |
246 if (joinedCiphersTls13.size() > 0 && SSL_CTX_set_ciphersuites(sslNativeHandle, joinedCiphersTls13.c_str()) != 1) | 279 if (joinedCiphersTls13.size() > 0 && SSL_CTX_set_ciphersuites(sslNativeHandle, joinedCiphersTls13.c_str()) != 1) |
247 { | 280 { |
248 OFCondition cond = DcmTLSTransportLayer::convertOpenSSLError(ERR_get_error(), OFTrue); | 281 OFCondition cond = MyConvertOpenSSLError(ERR_get_error(), OFTrue); |
249 throw OrthancException(ErrorCode_InternalError, "Unable to configure cipher suite for TLS 1.3. OpenSSL error: " + boost::lexical_cast<std::string>(cond.code()) + " - " + cond.text()); | 282 throw OrthancException(ErrorCode_InternalError, "Unable to configure cipher suite for TLS 1.3. OpenSSL error: " + boost::lexical_cast<std::string>(cond.code()) + " - " + cond.text()); |
250 } | 283 } |
251 | 284 |
252 } | 285 } |
253 #else | 286 #else |