Home | History | Annotate | Download | only in base
      1 /*
      2  *  Copyright 2004 The WebRTC Project Authors. All rights reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #if HAVE_CONFIG_H
     12 #include "config.h"
     13 #endif  // HAVE_CONFIG_H
     14 
     15 #include "webrtc/base/ssladapter.h"
     16 
     17 #include "webrtc/base/sslconfig.h"
     18 
     19 #if SSL_USE_SCHANNEL
     20 
     21 #include "schanneladapter.h"
     22 
     23 #elif SSL_USE_OPENSSL  // && !SSL_USE_SCHANNEL
     24 
     25 #include "openssladapter.h"
     26 
     27 #elif SSL_USE_NSS     // && !SSL_USE_CHANNEL && !SSL_USE_OPENSSL
     28 
     29 #include "nssstreamadapter.h"
     30 
     31 #endif  // SSL_USE_OPENSSL && !SSL_USE_SCHANNEL && !SSL_USE_NSS
     32 
     33 ///////////////////////////////////////////////////////////////////////////////
     34 
     35 namespace rtc {
     36 
     37 SSLAdapter*
     38 SSLAdapter::Create(AsyncSocket* socket) {
     39 #if SSL_USE_SCHANNEL
     40   return new SChannelAdapter(socket);
     41 #elif SSL_USE_OPENSSL  // && !SSL_USE_SCHANNEL
     42   return new OpenSSLAdapter(socket);
     43 #else  // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL
     44   delete socket;
     45   return NULL;
     46 #endif  // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL
     47 }
     48 
     49 ///////////////////////////////////////////////////////////////////////////////
     50 
     51 #if SSL_USE_OPENSSL
     52 
     53 bool InitializeSSL(VerificationCallback callback) {
     54   return OpenSSLAdapter::InitializeSSL(callback);
     55 }
     56 
     57 bool InitializeSSLThread() {
     58   return OpenSSLAdapter::InitializeSSLThread();
     59 }
     60 
     61 bool CleanupSSL() {
     62   return OpenSSLAdapter::CleanupSSL();
     63 }
     64 
     65 #elif SSL_USE_NSS  // !SSL_USE_OPENSSL
     66 
     67 bool InitializeSSL(VerificationCallback callback) {
     68   return NSSContext::InitializeSSL(callback);
     69 }
     70 
     71 bool InitializeSSLThread() {
     72   return NSSContext::InitializeSSLThread();
     73 }
     74 
     75 bool CleanupSSL() {
     76   return NSSContext::CleanupSSL();
     77 }
     78 
     79 #else  // !SSL_USE_OPENSSL && !SSL_USE_NSS
     80 
     81 bool InitializeSSL(VerificationCallback callback) {
     82   return true;
     83 }
     84 
     85 bool InitializeSSLThread() {
     86   return true;
     87 }
     88 
     89 bool CleanupSSL() {
     90   return true;
     91 }
     92 
     93 #endif  // !SSL_USE_OPENSSL && !SSL_USE_NSS
     94 
     95 ///////////////////////////////////////////////////////////////////////////////
     96 
     97 }  // namespace rtc
     98