00001 /* 00002 * 00003 * Copyright (C) 1998-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmtls 00019 * 00020 * Author: Marco Eichelberg 00021 * 00022 * Purpose: 00023 * classes: DcmTLSTransportLayer 00024 * 00025 * Last Update: $Author: meichel $ 00026 * Update Date: $Date: 2005/12/08 16:05:38 $ 00027 * CVS/RCS Revision: $Revision: 1.6 $ 00028 * Status: $State: Exp $ 00029 * 00030 * CVS/RCS Log at end of file 00031 * 00032 */ 00033 00034 #ifndef TLSLAYER_H 00035 #define TLSLAYER_H 00036 00037 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00038 #include "dcmtk/dcmnet/dcmlayer.h" /* for DcmTransportLayer */ 00039 #include "dcmtk/ofstd/ofstream.h" /* for ostream */ 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 /* WITH_OPENSSL */ 00249 00250 #endif 00251 00252 /* 00253 * $Log: tlslayer.h,v $ 00254 * Revision 1.6 2005/12/08 16:05:38 meichel 00255 * Changed include path schema for all DCMTK header files 00256 * 00257 * Revision 1.5 2003/12/05 10:38:55 joergr 00258 * Removed leading underscore characters from preprocessor symbols (reserved 00259 * symbols). 00260 * 00261 * Revision 1.4 2003/07/04 13:28:32 meichel 00262 * Added include for ofstream.h, to make sure ofstream is correctly defined 00263 * 00264 * Revision 1.3 2001/06/01 15:51:12 meichel 00265 * Updated copyright header 00266 * 00267 * Revision 1.2 2000/10/10 12:13:31 meichel 00268 * Added routines for printing certificates and connection parameters. 00269 * 00270 * Revision 1.1 2000/08/10 14:50:26 meichel 00271 * Added initial OpenSSL support. 00272 * 00273 * 00274 */ 00275