OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/tools/flip_server/spdy_ssl.h" | 5 #include "net/tools/flip_server/spdy_ssl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "openssl/err.h" | 8 #include "openssl/err.h" |
9 #include "openssl/ssl.h" | 9 #include "openssl/ssl.h" |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 VLOG(1) << "SSL CTX session expiry: " << session_expiration_time | 74 VLOG(1) << "SSL CTX session expiry: " << session_expiration_time |
75 << " seconds"; | 75 << " seconds"; |
76 SSL_CTX_set_timeout(state->ssl_ctx, session_expiration_time); | 76 SSL_CTX_set_timeout(state->ssl_ctx, session_expiration_time); |
77 | 77 |
78 #ifdef SSL_MODE_RELEASE_BUFFERS | 78 #ifdef SSL_MODE_RELEASE_BUFFERS |
79 VLOG(1) << "SSL CTX: Setting Release Buffers mode."; | 79 VLOG(1) << "SSL CTX: Setting Release Buffers mode."; |
80 SSL_CTX_set_mode(state->ssl_ctx, SSL_MODE_RELEASE_BUFFERS); | 80 SSL_CTX_set_mode(state->ssl_ctx, SSL_MODE_RELEASE_BUFFERS); |
81 #endif | 81 #endif |
82 | 82 |
83 #if !defined(OPENSSL_IS_BORINGSSL) | |
84 // Proper methods to disable compression don't exist until 0.9.9+. For now | 83 // Proper methods to disable compression don't exist until 0.9.9+. For now |
85 // we must manipulate the stack of compression methods directly. | 84 // we must manipulate the stack of compression methods directly. |
86 if (disable_ssl_compression) { | 85 if (disable_ssl_compression) { |
87 STACK_OF(SSL_COMP)* ssl_comp_methods = SSL_COMP_get_compression_methods(); | 86 STACK_OF(SSL_COMP)* ssl_comp_methods = SSL_COMP_get_compression_methods(); |
88 int num_methods = sk_SSL_COMP_num(ssl_comp_methods); | 87 int num_methods = sk_SSL_COMP_num(ssl_comp_methods); |
89 int i; | 88 int i; |
90 for (i = 0; i < num_methods; i++) { | 89 for (i = 0; i < num_methods; i++) { |
91 static_cast<void>(sk_SSL_COMP_delete(ssl_comp_methods, i)); | 90 static_cast<void>(sk_SSL_COMP_delete(ssl_comp_methods, i)); |
92 } | 91 } |
93 } | 92 } |
94 #endif | |
95 } | 93 } |
96 | 94 |
97 SSL* CreateSSLContext(SSL_CTX* ssl_ctx) { | 95 SSL* CreateSSLContext(SSL_CTX* ssl_ctx) { |
98 SSL* ssl = SSL_new(ssl_ctx); | 96 SSL* ssl = SSL_new(ssl_ctx); |
99 SSL_set_accept_state(ssl); | 97 SSL_set_accept_state(ssl); |
100 PrintSslError(); | 98 PrintSslError(); |
101 return ssl; | 99 return ssl; |
102 } | 100 } |
103 | 101 |
104 void PrintSslError() { | 102 void PrintSslError() { |
105 char buf[128]; // this buffer must be at least 120 chars long. | 103 char buf[128]; // this buffer must be at least 120 chars long. |
106 int error_num = ERR_get_error(); | 104 int error_num = ERR_get_error(); |
107 while (error_num != 0) { | 105 while (error_num != 0) { |
108 ERR_error_string_n(error_num, buf, sizeof(buf)); | 106 ERR_error_string_n(error_num, buf, sizeof(buf)); |
109 LOG(ERROR) << buf; | 107 LOG(ERROR) << buf; |
110 error_num = ERR_get_error(); | 108 error_num = ERR_get_error(); |
111 } | 109 } |
112 } | 110 } |
113 | 111 |
114 } // namespace net | 112 } // namespace net |
OLD | NEW |