00001 /* 00002 * 00003 * Copyright (C) 1998-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmtls 00015 * 00016 * Author: Marco Eichelberg 00017 * 00018 * Purpose: 00019 * classes: DcmTLSTransportLayer 00020 * 00021 * Last Update: $Author: joergr $ 00022 * Update Date: $Date: 2010-10-14 13:17:27 $ 00023 * CVS/RCS Revision: $Revision: 1.9 $ 00024 * Status: $State: Exp $ 00025 * 00026 * CVS/RCS Log at end of file 00027 * 00028 */ 00029 00030 #ifndef TLSLAYER_H 00031 #define TLSLAYER_H 00032 00033 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00034 #include "dcmtk/dcmnet/dcmlayer.h" /* for DcmTransportLayer */ 00035 #include "dcmtk/ofstd/ofstream.h" /* for ostream */ 00036 #include "dcmtk/oflog/oflog.h" 00037 00038 #ifdef WITH_OPENSSL 00039 BEGIN_EXTERN_C 00040 #include <openssl/ssl.h> 00041 END_EXTERN_C 00042 00043 OFLogger DCM_dcmtlsGetLogger(); 00044 00045 #define DCMTLS_TRACE(msg) OFLOG_TRACE(DCM_dcmtlsGetLogger(), msg) 00046 #define DCMTLS_DEBUG(msg) OFLOG_DEBUG(DCM_dcmtlsGetLogger(), msg) 00047 #define DCMTLS_INFO(msg) OFLOG_INFO(DCM_dcmtlsGetLogger(), msg) 00048 #define DCMTLS_WARN(msg) OFLOG_WARN(DCM_dcmtlsGetLogger(), msg) 00049 #define DCMTLS_ERROR(msg) OFLOG_ERROR(DCM_dcmtlsGetLogger(), msg) 00050 #define DCMTLS_FATAL(msg) OFLOG_FATAL(DCM_dcmtlsGetLogger(), msg) 00051 00056 enum DcmCertificateVerification 00057 { 00060 DCV_requireCertificate, 00061 00064 DCV_checkCertificate, 00065 00068 DCV_ignoreCertificate 00069 }; 00070 00071 00079 class DcmTLSTransportLayer: public DcmTransportLayer 00080 { 00081 public: 00082 00088 DcmTLSTransportLayer(int networkRole, const char *randFile); 00089 00091 virtual ~DcmTLSTransportLayer(); 00092 00104 virtual DcmTransportConnection *createConnection(int openSocket, OFBool useSecureLayer); 00105 00111 DcmTransportLayerStatus setPrivateKeyFile(const char *fileName, int fileType); 00112 00118 DcmTransportLayerStatus setCertificateFile(const char *fileName, int fileType); 00119 00124 OFBool checkPrivateKeyMatchesCertificate(); 00125 00131 DcmTransportLayerStatus addTrustedCertificateFile(const char *fileName, int fileType); 00132 00139 DcmTransportLayerStatus addTrustedCertificateDir(const char *pathName, int fileType); 00140 00148 DcmTransportLayerStatus setCipherSuites(const char *suites); 00149 00153 static unsigned long getNumberOfCipherSuites(); 00154 00159 static const char *getTLSCipherSuiteName(unsigned long idx); 00160 00165 static const char *getOpenSSLCipherSuiteName(unsigned long idx); 00166 00171 static const char *findOpenSSLCipherSuiteName(const char *tlsCipherSuiteName); 00172 00177 OFBool canWriteRandomSeed() { return canWriteRandseed; } 00178 00183 OFBool writeRandomSeed(const char *randFile); 00184 00193 void seedPRNG(const char *randFile); 00194 00200 void addPRNGseed(void *buf, size_t bufSize); 00201 00206 void setCertificateVerification(DcmCertificateVerification vtype); 00207 00214 void setPrivateKeyPasswd(const char *thePasswd); 00215 00219 void setPrivateKeyPasswdFromConsole(); 00220 00226 OFBool setTempDHParameters(const char *filename); 00227 00232 static OFString dumpX509Certificate(X509 *peerCertificate); 00233 00234 private: 00235 00237 DcmTLSTransportLayer(const DcmTLSTransportLayer&); 00238 00240 DcmTLSTransportLayer& operator=(const DcmTLSTransportLayer&); 00241 00243 SSL_CTX *transportLayerContext; 00244 00246 OFBool canWriteRandseed; 00247 00249 OFString privateKeyPasswd; 00250 00251 }; 00252 00253 #endif /* WITH_OPENSSL */ 00254 00255 #endif 00256 00257 /* 00258 * $Log: tlslayer.h,v $ 00259 * Revision 1.9 2010-10-14 13:17:27 joergr 00260 * Updated copyright header. Added reference to COPYRIGHT file. 00261 * 00262 * Revision 1.8 2009-11-18 12:11:19 uli 00263 * Switched to logging mechanism provided by the "new" oflog module. 00264 * 00265 * Revision 1.7 2006-08-15 16:02:55 meichel 00266 * Updated the code in module dcmtls to correctly compile when 00267 * all standard C++ classes remain in namespace std. 00268 * 00269 * Revision 1.6 2005/12/08 16:05:38 meichel 00270 * Changed include path schema for all DCMTK header files 00271 * 00272 * Revision 1.5 2003/12/05 10:38:55 joergr 00273 * Removed leading underscore characters from preprocessor symbols (reserved 00274 * symbols). 00275 * 00276 * Revision 1.4 2003/07/04 13:28:32 meichel 00277 * Added include for ofstream.h, to make sure ofstream is correctly defined 00278 * 00279 * Revision 1.3 2001/06/01 15:51:12 meichel 00280 * Updated copyright header 00281 * 00282 * Revision 1.2 2000/10/10 12:13:31 meichel 00283 * Added routines for printing certificates and connection parameters. 00284 * 00285 * Revision 1.1 2000/08/10 14:50:26 meichel 00286 * Added initial OpenSSL support. 00287 * 00288 * 00289 */ 00290