Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: runtime/bin/security_context.h

Issue 2903743002: Porting SecureSocket to use BoringSSL on OSX (Closed)
Patch Set: Additional cleanup Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef RUNTIME_BIN_SECURITY_CONTEXT_H_
6 #define RUNTIME_BIN_SECURITY_CONTEXT_H_
7
8 #include <openssl/ssl.h>
9 #include <openssl/x509.h>
10
11 #include "bin/lockers.h"
12 #include "bin/reference_counting.h"
13 #include "bin/socket.h"
14
15 namespace dart {
16 namespace bin {
17
18 // Forward declaration
19 class SSLFilter;
20
21 class SSLCertContext : public ReferenceCounted<SSLCertContext> {
22 public:
23 static const intptr_t kApproximateSize;
24 static const int kSecurityContextNativeFieldIndex = 0;
25 static const int kX509NativeFieldIndex = 0;
26
27 explicit SSLCertContext(SSL_CTX* context)
28 : ReferenceCounted(),
29 context_(context),
30 alpn_protocol_string_(NULL),
31 trust_builtin_(false) {}
32
33 ~SSLCertContext() {
34 SSL_CTX_free(context_);
35 if (alpn_protocol_string_ != NULL) {
36 free(alpn_protocol_string_);
37 }
38 }
39
40 static SSLCertContext* GetSecurityContext(Dart_NativeArguments args);
41 static const char* GetPasswordArgument(Dart_NativeArguments args,
42 intptr_t index);
43 static void SetAlpnProtocolList(Dart_Handle protocols_handle,
44 SSL* ssl,
45 SSLCertContext* context,
46 bool is_server);
47
48 void SetTrustedCertificatesBytes(Dart_Handle cert_bytes,
49 const char* password);
50
51 void SetClientAuthoritiesBytes(Dart_Handle client_authorities_bytes,
52 const char* password);
53
54 int UseCertificateChainBytes(Dart_Handle cert_chain_bytes,
55 const char* password);
56
57 void TrustBuiltinRoots();
58
59 SSL_CTX* context() const { return context_; }
60
61 uint8_t* alpn_protocol_string() const { return alpn_protocol_string_; }
62
63 void set_alpn_protocol_string(uint8_t* protocol_string) {
64 if (alpn_protocol_string_ != NULL) {
65 free(alpn_protocol_string_);
66 }
67 alpn_protocol_string_ = protocol_string;
68 }
69
70 bool trust_builtin() const { return trust_builtin_; }
71
72 void set_trust_builtin(bool trust_builtin) { trust_builtin_ = trust_builtin; }
73
74 void RegisterCallbacks(SSLFilter* filter);
75
76 private:
77 void LoadRootCertFile(const char* file);
78 void LoadRootCertCache(const char* cache);
79
80 SSL_CTX* context_;
81 uint8_t* alpn_protocol_string_;
82
83 bool trust_builtin_;
84
85 DISALLOW_COPY_AND_ASSIGN(SSLCertContext);
86 };
87
88 } // namespace bin
89 } // namespace dart
90
91 #endif // RUNTIME_BIN_SECURITY_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698