00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef TLSLAYER_H
00035 #define TLSLAYER_H
00036
00037 #include "dcmtk/config/osconfig.h"
00038 #include "dcmtk/dcmnet/dcmlayer.h"
00039 #include "dcmtk/ofstd/ofstream.h"
00040
00041 #ifdef WITH_OPENSSL
00042 BEGIN_EXTERN_C
00043 #include <openssl/ssl.h>
00044 END_EXTERN_C
00045
00050 enum DcmCertificateVerification
00051 {
00054 DCV_requireCertificate,
00055
00058 DCV_checkCertificate,
00059
00062 DCV_ignoreCertificate
00063 };
00064
00065
00073 class DcmTLSTransportLayer: public DcmTransportLayer
00074 {
00075 public:
00076
00082 DcmTLSTransportLayer(int networkRole, const char *randFile);
00083
00085 virtual ~DcmTLSTransportLayer();
00086
00098 virtual DcmTransportConnection *createConnection(int openSocket, OFBool useSecureLayer);
00099
00105 DcmTransportLayerStatus setPrivateKeyFile(const char *fileName, int fileType);
00106
00112 DcmTransportLayerStatus setCertificateFile(const char *fileName, int fileType);
00113
00118 OFBool checkPrivateKeyMatchesCertificate();
00119
00125 DcmTransportLayerStatus addTrustedCertificateFile(const char *fileName, int fileType);
00126
00133 DcmTransportLayerStatus addTrustedCertificateDir(const char *pathName, int fileType);
00134
00142 DcmTransportLayerStatus setCipherSuites(const char *suites);
00143
00147 static unsigned long getNumberOfCipherSuites();
00148
00153 static const char *getTLSCipherSuiteName(unsigned long idx);
00154
00159 static const char *getOpenSSLCipherSuiteName(unsigned long idx);
00160
00165 static const char *findOpenSSLCipherSuiteName(const char *tlsCipherSuiteName);
00166
00171 OFBool canWriteRandomSeed() { return canWriteRandseed; }
00172
00177 OFBool writeRandomSeed(const char *randFile);
00178
00187 void seedPRNG(const char *randFile);
00188
00194 void addPRNGseed(void *buf, size_t bufSize);
00195
00200 void setCertificateVerification(DcmCertificateVerification vtype);
00201
00208 void setPrivateKeyPasswd(const char *thePasswd);
00209
00213 void setPrivateKeyPasswdFromConsole();
00214
00220 OFBool setTempDHParameters(const char *filename);
00221
00227 static void printX509Certificate(ostream &out, X509 *peerCertificate);
00228
00229 private:
00230
00232 DcmTLSTransportLayer(const DcmTLSTransportLayer&);
00233
00235 DcmTLSTransportLayer& operator=(const DcmTLSTransportLayer&);
00236
00238 SSL_CTX *transportLayerContext;
00239
00241 OFBool canWriteRandseed;
00242
00244 OFString privateKeyPasswd;
00245
00246 };
00247
00248 #endif
00249
00250 #endif
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275