OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROMEOS_NETWORK_CERTIFICATE_HELPER_H_ |
| 6 #define CHROMEOS_NETWORK_CERTIFICATE_HELPER_H_ |
| 7 |
| 8 #include <cert.h> |
| 9 #include <string> |
| 10 |
| 11 #include "chromeos/chromeos_export.h" |
| 12 #include "net/cert/cert_type.h" |
| 13 #include "net/cert/x509_certificate.h" |
| 14 |
| 15 namespace chromeos { |
| 16 namespace certificate { |
| 17 |
| 18 // Selected functions from chrome/common/net/x509_certificate_model.cc |
| 19 |
| 20 // Decodes the certificate type from |cert|. |
| 21 CHROMEOS_EXPORT net::CertType GetCertType( |
| 22 net::X509Certificate::OSCertHandle cert_handle); |
| 23 |
| 24 // Extracts the token name from |cert|->slot if it exists or returns an empty |
| 25 // string. |
| 26 CHROMEOS_EXPORT std::string GetCertTokenName( |
| 27 net::X509Certificate::OSCertHandle cert_handle); |
| 28 |
| 29 // Returns the common name for |cert_handle|->issuer or |alternative_text| if |
| 30 // the common name is missing or empty. |
| 31 CHROMEOS_EXPORT std::string GetIssuerCommonName( |
| 32 net::X509Certificate::OSCertHandle cert_handle, |
| 33 const std::string& alternative_text); |
| 34 |
| 35 // Returns the common name for |cert_handle|->subject converted to unicode, |
| 36 // or |cert_handle|->nickname if the subject name is unavailable or empty. |
| 37 // NOTE: Unlike x509_certificate_model::GetCertNameOrNickname in src/chrome, |
| 38 // the raw unformated name or nickname will not be included in the returned |
| 39 // value (see GetCertAsciiNameOrNickname instead). |
| 40 CHROMEOS_EXPORT std::string GetCertNameOrNickname( |
| 41 net::X509Certificate::OSCertHandle cert_handle); |
| 42 |
| 43 // Returns the unformated ASCII common name for |cert_handle|->subject. |
| 44 CHROMEOS_EXPORT std::string GetCertAsciiNameOrNickname( |
| 45 net::X509Certificate::OSCertHandle cert_handle); |
| 46 |
| 47 } // namespace certificate |
| 48 } // namespace chromeos |
| 49 |
| 50 #endif // CHROMEOS_NETWORK_CERTIFICATE_HELPER_H_ |
OLD | NEW |