Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | List of all members
Botan::Path_Validation_Result Class Referencefinal

`#include <x509path.h>`

## Public Types
typedef Certificate_Status_Code | Code

## Public Member Functions
const CertificatePathStatusCodes & | all_statuses () const
const std::vector< std::shared_ptr< const X509_Certificate > > & | cert_path () const
bool | no_warnings () const
| Path_Validation_Result (CertificatePathStatusCodes status, std::vector< std::shared_ptr< const X509_Certificate >> &&cert_chain)
| Path_Validation_Result (Certificate_Status_Code status)
Certificate_Status_Code | result () const
std::string | result_string () const
bool | successful_validation () const
const X509_Certificate & | trust_root () const
std::set< std::string > | trusted_hashes () const
CertificatePathStatusCodes | warnings () const
std::string | warnings_string () const

## Static Public Member Functions
static const char * | status_string (Certificate_Status_Code code)

## Detailed Description

Represents the result of a PKIX path validation

Definition at line 125 of file x509path.h.

## Member Typedef Documentation

typedef Certificate_Status_Code Botan::Path_Validation_Result::Code

Definition at line 128 of file x509path.h.

## Constructor & Destructor Documentation

Botan::Path_Validation_Result::Path_Validation_Result | ( | CertificatePathStatusCodes | status,
|  | std::vector< std::shared_ptr< const X509_Certificate >> && | cert_chain
| ) |  |

Create a Path_Validation_Result

Parameters

  status | list of validation status codes
  cert_chain | the certificate chain that was validated

Definition at line 1004 of file x509path.cpp.

1005 :
1006 m_all_status(status),
1007 m_warnings(find_warnings(m_all_status)),
1008 m_cert_path(cert_chain),
1009 m_overall(PKIX::overall_status(m_all_status))
1010 {
1011 }
Botan::PKIX::overall_status
Certificate_Status_Code overall_status(const CertificatePathStatusCodes &cert_status)
Definition: x509path.cpp:813

Botan::Path_Validation_Result::Path_Validation_Result | ( | Certificate_Status_Code | status | ) |
| inline explicit

Create a Path_Validation_Result

Parameters

  status | validation status code

Definition at line 202 of file x509path.h.

202 : m_overall(status) {}

## Member Function Documentation

const CertificatePathStatusCodes& Botan::Path_Validation_Result::all_statuses | ( |  | ) | const
| inline

Returns
  a set of status codes for each certificate in the chain

Definition at line 166 of file x509path.h.

167 { return m_all_status; }

const std::vector<std::shared_ptr<const X509_Certificate> >& Botan::Path_Validation_Result::cert_path | ( |  | ) | const
| inline

Returns
  the full path from subject to trust root This path may be empty

Definition at line 146 of file x509path.h.

146 { return m_cert_path; }

bool Botan::Path_Validation_Result::no_warnings | ( |  | ) | const

Returns
  true iff no warnings occured during validation

Definition at line 1038 of file x509path.cpp.

1039 {
1040 for(auto status_set_i : m_warnings)
1041 if(!status_set_i.empty())
1042 return false;
1043 return true;
1044 }

Certificate_Status_Code Botan::Path_Validation_Result::result | ( |  | ) | const
| inline

Returns
  overall validation result code

Definition at line 161 of file x509path.h.

Referenced by result_string(), successful_validation(), and trust_root().

161 { return m_overall; }

std::string Botan::Path_Validation_Result::result_string | ( |  | ) | const

Returns
  string representation of the validation result

Definition at line 1051 of file x509path.cpp.

References result(), and status_string().

1052 {
1053 return status_string(result());
1054 }
Botan::Path_Validation_Result::result
Certificate_Status_Code result() const
Definition: x509path.h:161
Botan::Path_Validation_Result::status_string
static const char * status_string(Certificate_Status_Code code)
Definition: x509path.cpp:1056

const char * Botan::Path_Validation_Result::status_string | ( | Certificate_Status_Code | code | ) |
| static

Parameters

  code | validation status code

Returns
  corresponding validation status message

Definition at line 1056 of file x509path.cpp.

References Botan::to_string().

Referenced by result_string(), and warnings_string().

1057 {
1058 if(const char* s = to_string(code))
1059 return s;
1060
1061 return "Unknown error";
1062 }
Botan::to_string
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition: exceptn.cpp:11

bool Botan::Path_Validation_Result::successful_validation | ( |  | ) | const

Returns
  true iff the validation was successful

Definition at line 1031 of file x509path.cpp.

References Botan::OCSP_RESPONSE_GOOD, result(), Botan::VALID_CRL_CHECKED, and Botan::VERIFIED.

1032 {
1033 return (result() == Certificate_Status_Code::VERIFIED ||
1034 result() == Certificate_Status_Code::OCSP_RESPONSE_GOOD ||
1035 result() == Certificate_Status_Code::VALID_CRL_CHECKED);
1036 }
Botan::Certificate_Status_Code::VALID_CRL_CHECKED
Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD
Botan::Path_Validation_Result::result
Certificate_Status_Code result() const
Definition: x509path.h:161
Botan::Certificate_Status_Code::VERIFIED

const X509_Certificate & Botan::Path_Validation_Result::trust_root | ( |  | ) | const

Returns
  the trust root of the validation if successful throws an exception if the validation failed

Definition at line 1013 of file x509path.cpp.

References result(), and Botan::VERIFIED.

1014 {
1015 if(m_cert_path.empty())
1016 throw Invalid_State("Path_Validation_Result::trust_root no path set");
1017 if(result() != Certificate_Status_Code::VERIFIED)
1018 throw Invalid_State("Path_Validation_Result::trust_root meaningless with invalid status");
1019
1020 return *m_cert_path[m_cert_path.size()-1];
1021 }
Botan::Path_Validation_Result::result
Certificate_Status_Code result() const
Definition: x509path.h:161
Botan::Certificate_Status_Code::VERIFIED

std::set< std::string > Botan::Path_Validation_Result::trusted_hashes | ( |  | ) | const

Returns
  the set of hash functions you are implicitly trusting by trusting this result.

Definition at line 1023 of file x509path.cpp.

1024 {
1025 std::set<std::string> hashes;
1026 for(size_t i = 0; i != m_cert_path.size(); ++i)
1027 hashes.insert(m_cert_path[i]->hash_used_for_signature());
1028 return hashes;
1029 }

CertificatePathStatusCodes Botan::Path_Validation_Result::warnings | ( |  | ) | const

Returns
  the subset of status codes that are warnings

Definition at line 1046 of file x509path.cpp.

1047 {
1048 return m_warnings;
1049 }

std::string Botan::Path_Validation_Result::warnings_string | ( |  | ) | const

Returns
  string representation of the warnings

Definition at line 1064 of file x509path.cpp.

References status_string(), and Botan::ASN1::to_string().

1065 {
1066 const std::string sep(", ");
1067 std::string res;
1068 for(size_t i = 0; i < m_warnings.size(); i++)
1069 {
1070 for(auto code : m_warnings[i])
1071 res += "[" + std::to_string(i) + "] " + status_string(code) + sep;
1072 }
1073 // remove last sep
1074 if(res.size() >= sep.size())
1075 res = res.substr(0, res.size() - sep.size());
1076 return res;
1077 }
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:213
Botan::Path_Validation_Result::status_string
static const char * status_string(Certificate_Status_Code code)
Definition: x509path.cpp:1056

The documentation for this class was generated from the following files:

- src/lib/x509/x509path.h
- src/lib/x509/x509path.cpp