| 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 "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 Loading... |
| 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 |
| OLD | NEW |