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

Side by Side Diff: remoting/host/host_key_pair.cc

Issue 10919277: Handle certificate generation errors in chromoting host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/host_key_pair.h ('k') | remoting/host/plugin/host_script_object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "remoting/host/host_key_pair.h" 5 #include "remoting/host/host_key_pair.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 CHECK(key_->ExportPrivateKey(&key_bytes)); 98 CHECK(key_->ExportPrivateKey(&key_bytes));
99 return crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes); 99 return crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes);
100 } 100 }
101 101
102 std::string HostKeyPair::GenerateCertificate() const { 102 std::string HostKeyPair::GenerateCertificate() const {
103 scoped_refptr<net::X509Certificate> cert = 103 scoped_refptr<net::X509Certificate> cert =
104 net::X509Certificate::CreateSelfSigned( 104 net::X509Certificate::CreateSelfSigned(
105 key_.get(), "CN=chromoting", 105 key_.get(), "CN=chromoting",
106 base::RandInt(1, std::numeric_limits<int>::max()), 106 base::RandInt(1, std::numeric_limits<int>::max()),
107 base::TimeDelta::FromDays(1)); 107 base::TimeDelta::FromDays(1));
108 if (!cert)
109 return std::string();
110
108 std::string encoded; 111 std::string encoded;
109 bool result = net::X509Certificate::GetDEREncoded(cert->os_cert_handle(), 112 bool result = net::X509Certificate::GetDEREncoded(cert->os_cert_handle(),
110 &encoded); 113 &encoded);
111 CHECK(result); 114 CHECK(result);
112 return encoded; 115 return encoded;
113 } 116 }
114 117
115 } // namespace remoting 118 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_key_pair.h ('k') | remoting/host/plugin/host_script_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698