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

Side by Side Diff: net/ssl/ssl_platform_key_nss.cc

Issue 1232553003: Add new certificateProvider extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ssl/ssl_platform_key.h" 5 #include "net/ssl/ssl_platform_key.h"
6 6
7 #include <keyhi.h> 7 #include <keyhi.h>
8 #include <pk11pub.h> 8 #include <pk11pub.h>
9 #include <prerror.h> 9 #include <prerror.h>
10 10
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 private: 147 private:
148 SSLPrivateKey::Type type_; 148 SSLPrivateKey::Type type_;
149 crypto::ScopedSECKEYPrivateKey key_; 149 crypto::ScopedSECKEYPrivateKey key_;
150 150
151 DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyNSS); 151 DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyNSS);
152 }; 152 };
153 153
154 } // namespace 154 } // namespace
155 155
156 FetchPrivateKeyFunc* fetch_private_key_func = nullptr;
157
156 scoped_ptr<SSLPrivateKey> FetchClientCertPrivateKey( 158 scoped_ptr<SSLPrivateKey> FetchClientCertPrivateKey(
157 X509Certificate* certificate, 159 X509Certificate* certificate,
158 scoped_refptr<base::SequencedTaskRunner> task_runner) { 160 scoped_refptr<base::SequencedTaskRunner> task_runner) {
159 crypto::ScopedSECKEYPrivateKey key( 161 crypto::ScopedSECKEYPrivateKey key(
160 PK11_FindKeyByAnyCert(certificate->os_cert_handle(), nullptr)); 162 PK11_FindKeyByAnyCert(certificate->os_cert_handle(), nullptr));
161 if (!key) 163 if (!key) {
164 if (fetch_private_key_func) {
165 return fetch_private_key_func(certificate);
166 }
162 return nullptr; 167 return nullptr;
168 }
163 169
164 KeyType nss_type = SECKEY_GetPrivateKeyType(key.get()); 170 KeyType nss_type = SECKEY_GetPrivateKeyType(key.get());
165 SSLPrivateKey::Type type; 171 SSLPrivateKey::Type type;
166 switch (nss_type) { 172 switch (nss_type) {
167 case rsaKey: 173 case rsaKey:
168 type = SSLPrivateKey::Type::RSA; 174 type = SSLPrivateKey::Type::RSA;
169 break; 175 break;
170 case ecKey: 176 case ecKey:
171 type = SSLPrivateKey::Type::ECDSA; 177 type = SSLPrivateKey::Type::ECDSA;
172 break; 178 break;
173 default: 179 default:
174 LOG(ERROR) << "Unknown key type: " << nss_type; 180 LOG(ERROR) << "Unknown key type: " << nss_type;
175 return nullptr; 181 return nullptr;
176 } 182 }
177 return make_scoped_ptr(new ThreadedSSLPrivateKey( 183 return make_scoped_ptr(new ThreadedSSLPrivateKey(
178 make_scoped_ptr(new SSLPlatformKeyNSS(type, key.Pass())), 184 make_scoped_ptr(new SSLPlatformKeyNSS(type, key.Pass())),
179 task_runner.Pass())); 185 task_runner.Pass()));
180 } 186 }
181 187
182 } // namespace net 188 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698