# HG changeset patch # User Sebastien Jodogne # Date 1717172624 -7200 # Node ID 3431497624765de664863c1069559c6a1cc9cd93 # Parent b1a18218860cd73177a01b45b7b6d692a718e079 fix build with DCMTK <= 3.6.6 diff -r b1a18218860c -r 343149762476 OrthancFramework/Sources/DicomNetworking/Internals/DicomTls.cpp --- a/OrthancFramework/Sources/DicomNetworking/Internals/DicomTls.cpp Fri May 31 16:56:35 2024 +0200 +++ b/OrthancFramework/Sources/DicomNetworking/Internals/DicomTls.cpp Fri May 31 18:23:44 2024 +0200 @@ -61,6 +61,39 @@ #endif +#if DCMTK_VERSION_NUMBER >= 367 + static OFCondition MyConvertOpenSSLError(unsigned long errorCode, OFBool logAsError) + { + return DcmTLSTransportLayer::convertOpenSSLError(errorCode, logAsError); + } +#else + static OFCondition MyConvertOpenSSLError(unsigned long errorCode, OFBool logAsError) + { + if (errorCode == 0) + { + return EC_Normal; + } + else + { + const char *err = ERR_reason_error_string(errorCode); + if (err == NULL) + { + err = "OpenSSL error"; + } + + if (logAsError) + { + DCMTLS_ERROR("OpenSSL error " << STD_NAMESPACE hex << STD_NAMESPACE setfill('0') + << STD_NAMESPACE setw(8) << errorCode << ": " << err); + } + + // The "2" below corresponds to the same error code as "DCMTLS_EC_FailedToSetCiphersuites" + return OFCondition(OFM_dcmtls, 2, OF_error, err); + } + } +#endif + + DcmTLSTransportLayer* InitializeDicomTls(T_ASC_Network *network, T_ASC_NetworkRole role, const std::string& ownPrivateKeyPath, @@ -239,13 +272,13 @@ if (joinedCiphersTls.size() > 0 && SSL_CTX_set_cipher_list(sslNativeHandle, joinedCiphersTls.c_str()) != 1) { - OFCondition cond = DcmTLSTransportLayer::convertOpenSSLError(ERR_get_error(), OFTrue); + OFCondition cond = MyConvertOpenSSLError(ERR_get_error(), OFTrue); throw OrthancException(ErrorCode_InternalError, "Unable to configure cipher suite. OpenSSL error: " + boost::lexical_cast(cond.code()) + " - " + cond.text()); } if (joinedCiphersTls13.size() > 0 && SSL_CTX_set_ciphersuites(sslNativeHandle, joinedCiphersTls13.c_str()) != 1) { - OFCondition cond = DcmTLSTransportLayer::convertOpenSSLError(ERR_get_error(), OFTrue); + OFCondition cond = MyConvertOpenSSLError(ERR_get_error(), OFTrue); throw OrthancException(ErrorCode_InternalError, "Unable to configure cipher suite for TLS 1.3. OpenSSL error: " + boost::lexical_cast(cond.code()) + " - " + cond.text()); }