comparison OrthancFramework/Sources/DicomNetworking/Internals/DicomTls.cpp @ 5598:317850cd46bc

fix DicomTlsTrustedCertificates configuration that should not be mandatory if DicomTlsRemoteCertificateRequired is false
author Alain Mazy <am@orthanc.team>
date Tue, 07 May 2024 19:20:01 +0200
parents 33f8e180edcf
children 335e2079de1f cfb67c7ccb4d
comparison
equal deleted inserted replaced
5585:5df6d2a8d9f2 5598:317850cd46bc
74 role != NET_REQUESTOR) 74 role != NET_REQUESTOR)
75 { 75 {
76 throw OrthancException(ErrorCode_ParameterOutOfRange, "Unknown role"); 76 throw OrthancException(ErrorCode_ParameterOutOfRange, "Unknown role");
77 } 77 }
78 78
79 if (!SystemToolbox::IsRegularFile(trustedCertificatesPath)) 79 if (requireRemoteCertificate && !SystemToolbox::IsRegularFile(trustedCertificatesPath))
80 { 80 {
81 throw OrthancException(ErrorCode_InexistentFile, "Cannot read file with trusted certificates for DICOM TLS: " + 81 throw OrthancException(ErrorCode_InexistentFile, "Cannot read file with trusted certificates for DICOM TLS: " +
82 trustedCertificatesPath); 82 trustedCertificatesPath);
83 } 83 }
84 84
118 118
119 std::unique_ptr<DcmTLSTransportLayer> tls( 119 std::unique_ptr<DcmTLSTransportLayer> tls(
120 new DcmTLSTransportLayer(tmpRole /*opt_networkRole*/, NULL /*opt_readSeedFile*/, 120 new DcmTLSTransportLayer(tmpRole /*opt_networkRole*/, NULL /*opt_readSeedFile*/,
121 OFFalse /*initializeOpenSSL, done by Orthanc::Toolbox::InitializeOpenSsl()*/)); 121 OFFalse /*initializeOpenSSL, done by Orthanc::Toolbox::InitializeOpenSsl()*/));
122 122
123 if (IsFailure(tls->addTrustedCertificateFile(trustedCertificatesPath.c_str(), DCF_Filetype_PEM /*opt_keyFileFormat*/))) 123 if (requireRemoteCertificate && IsFailure(tls->addTrustedCertificateFile(trustedCertificatesPath.c_str(), DCF_Filetype_PEM /*opt_keyFileFormat*/)))
124 { 124 {
125 throw OrthancException(ErrorCode_BadFileFormat, "Cannot parse PEM file with trusted certificates for DICOM TLS: " + 125 throw OrthancException(ErrorCode_BadFileFormat, "Cannot parse PEM file with trusted certificates for DICOM TLS: " +
126 trustedCertificatesPath); 126 trustedCertificatesPath);
127 } 127 }
128 128