It works well when building and executing in linux environment (in my WSL2 ubuntu), But in windows, I got below errors when build the project
[build] C:\fly_dev_3\cmake_try\4-sample-win\main.cpp(147,5): error C2653: 'DcmTLSTransportLayer': is not a class or namespace name [C:\fly_dev_3\cmake_try\4-sample-win\out\build\Test\MyTest.vcxproj]
[build] C:\fly_dev_3\cmake_try\4-sample-win\main.cpp(147,27): error C3861: 'initializeOpenSSL': identifier not found [C:\fly_dev_3\cmake_try\4-sample-win\out\build\Test\MyTest.vcxproj]
_I find that the windows dcmtk package in dcmtk/config/osconfig.h file the WITHOPENSSL not defined
Seems the feature not truly enabled.
Environment
OS: Windows 10
Compiler: Visual Studio 2022 X64
To Reproduce
Steps to reproduce the behavior:
./vcpkg install dcmtk[openssl]
Create a cmake project using the following code
#include <iostream>
#include "dcmtk/dcmdata/dctk.h"
#include "dcmtk/dcmnet/assoc.h"
#include <dcmtk/dcmnet/dimse.h>
#include <dcmtk/dcmtls/tlslayer.h>
using namespace std;
int opt_acse_timeout = 30;
int main(int, char **)
{
DcmTLSTransportLayer::initializeOpenSSL(); // initialize OpenSSL library
T_ASC_Network *net; // network struct, contains DICOM upper layer FSM etc.
OFCondition cond = ASC_initializeNetwork(NET_REQUESTOR, 0, opt_acse_timeout, &net);
if (!cond.good())
{
return 1;
}
T_ASC_Parameters *params; // parameters of association request
cond = ASC_createAssociationParameters(¶ms, ASC_DEFAULTMAXPDU);
if (!cond.good())
{
return 1;
}
///////////////////////TLS//////////////////////////
{
T_ASC_NetworkRole opt_networkRole = NET_REQUESTOR;
DcmTLSTransportLayer *tLayer = new DcmTLSTransportLayer(opt_networkRole, OFnullptr, OFFalse);
auto rootCAFile = "/mnt/c/test/rootCA.cer";
cond = tLayer->addTrustedCertificateFile(rootCAFile, DcmKeyFileFormat::DCF_Filetype_PEM);
if (cond.bad())
{
return 1;
}
// skip cert check
tLayer->setCRLverification(TCR_noCRL);
cond = tLayer->setTLSProfile(DcmTLSSecurityProfile::TSP_Profile_BCP_195_RFC_8996);
if (cond.bad())
{
return 1;
}
tLayer->setCertificateVerification(DcmCertificateVerification::DCV_requireCertificate);
cond = ASC_setTransportLayer(net, tLayer, 0);
if (cond.bad())
{
return 1;
}
cond = ASC_setTransportLayerType(params, true);
if (cond.bad())
{
return 1;
}
}
// set calling and called AE titles
ASC_setAPTitles(params, "ECHOSCU", "ANY-SCP", NULL);
ASC_setPresentationAddresses(params, "172.17.112.1", "172.17.112.1:8889");
// list of transfer syntaxes, only a single entry here
const char *ts[] = {UID_LittleEndianImplicitTransferSyntax};
// add presentation context to association request
int preId = 1;
ASC_addPresentationContext(params, preId, UID_VerificationSOPClass, ts, 1);
// request DICOM association
T_ASC_Association *assoc;
cond = ASC_requestAssociation(net, params, &assoc);
if (!cond.good())
{
return 1;
}
{
T_DIMSE_Message msg;
memset((char *)&msg, 0, sizeof(msg));
msg.msg.CStoreRQ.MessageID = 1;
msg.CommandField = DIMSE_C_STORE_RQ;
msg.msg.CStoreRQ.DataSetType = T_DIMSE_DataSetType::DIMSE_DATASET_PRESENT;
strcpy(msg.msg.CStoreRQ.AffectedSOPClassUID, "1.2.840.10008.5.1.4.1.1.2"); // 不传文件名会unknown开头
strcpy(msg.msg.CStoreRQ.AffectedSOPInstanceUID, "1.2.3.4.5"); // 设置受影响的SOP实例UID
auto dcmFile = "/mnt/c/test/CT.DCM";
cond = DIMSE_sendMessageUsingFileData(assoc, preId, &msg, NULL, dcmFile, NULL, NULL);
if (!cond.good())
{
return 1;
}
}
cond = ASC_releaseAssociation(assoc); // release association
if (!cond.good())
{
return 1;
}
cond = ASC_destroyAssociation(&assoc); // delete assoc structure
if (!cond.good())
{
return 1;
}
cond = ASC_dropNetwork(&net); // delete net structure
if (!cond.good())
{
return 1;
}
}
Build failed, because the macro WITH_OPENSSL not defined, so the tlslayer.h not contain the tls related classes.
Expected behavior
Should build success like in linux env
Failure logs
···
[build] C:\fly_dev_3\cmake_try\4-sample-win\main.cpp(147,5): error C2653: 'DcmTLSTransportLayer': is not a class or namespace name [C:\fly_dev_3\cmake_try\4-sample-win\out\build\Test\MyTest.vcxproj]
[build] C:\fly_dev_3\cmake_try\4-sample-win\main.cpp(147,27): error C3861: 'initializeOpenSSL': identifier not found [C:\fly_dev_3\cmake_try\4-sample-win\out\build\Test\MyTest.vcxproj]
[build] C:\fly_dev_3\cmake_try\4-sample-win\main.cpp(149,5): error C2065: 'DcmTLSTransportLayer': undeclared identifier [C:\fly_dev_3\cmake_try\4-sample-win\out\build\Test\MyTest.vcxproj]
···
Additional context
If I define the WITH_OPENSSL in my code , then build. it will return the LINK error. So I believe the DCMTK not enable the OPENSSL feature in windowsX64
below is the vcpkg list
PS C:\Debug> vcpkg list
boost-uninstall:x64-linux 1.84.0 Internal vcpkg port used to uninstall Boost
dcmtk:x64-linux 3.6.8#3 This DICOM ToolKit (DCMTK) package consists of s...
dcmtk:x64-windows 3.6.8#3 This DICOM ToolKit (DCMTK) package consists of s...
dcmtk[openssl]:x64-linux Enable OpenSSL
dcmtk[openssl]:x64-windows Enable OpenSSL
openssl:x64-linux 3.3.0 OpenSSL is an open source project that provides ...
openssl:x64-windows 3.3.0 OpenSSL is an open source project that provides ...
vcpkg-cmake-config:x64-linux 2022-02-06#1
vcpkg-cmake-config:x64-windows 2022-02-06#1
vcpkg-cmake-get-vars:x64-linux 2023-12-31
vcpkg-cmake-get-vars:x64-windows 2023-12-31
vcpkg-cmake:x64-linux 2023-05-04
vcpkg-cmake:x64-windows 2023-05-04
Describe the bug I use the command to install the dcmtk with openssl feature on
Then I write some sample code using dcmtk tls like
It works well when building and executing in linux environment (in my WSL2 ubuntu), But in windows, I got below errors when build the project
_I find that the windows dcmtk package in dcmtk/config/osconfig.h file the WITHOPENSSL not defined
Seems the feature not truly enabled.
Environment
To Reproduce Steps to reproduce the behavior:
Expected behavior Should build success like in linux env
Failure logs ··· [build] C:\fly_dev_3\cmake_try\4-sample-win\main.cpp(147,5): error C2653: 'DcmTLSTransportLayer': is not a class or namespace name [C:\fly_dev_3\cmake_try\4-sample-win\out\build\Test\MyTest.vcxproj] [build] C:\fly_dev_3\cmake_try\4-sample-win\main.cpp(147,27): error C3861: 'initializeOpenSSL': identifier not found [C:\fly_dev_3\cmake_try\4-sample-win\out\build\Test\MyTest.vcxproj] [build] C:\fly_dev_3\cmake_try\4-sample-win\main.cpp(149,5): error C2065: 'DcmTLSTransportLayer': undeclared identifier [C:\fly_dev_3\cmake_try\4-sample-win\out\build\Test\MyTest.vcxproj] ···
Additional context If I define the WITH_OPENSSL in my code , then build. it will return the LINK error. So I believe the DCMTK not enable the OPENSSL feature in windowsX64
below is the vcpkg list