Botan 2.1.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 Reference

`#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
| 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

## 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 110 of file x509path.h.

## Member Typedef Documentation

typedef Certificate_Status_Code Botan::Path_Validation_Result::Code

Definition at line 113 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 692 of file x509path.cpp.

693 :
694 m_all_status(status),
695 m_cert_path(cert_chain),
696 m_overall(PKIX::overall_status(m_all_status))
697 {
698 }
Botan::PKIX::overall_status
Certificate_Status_Code BOTAN_DLL overall_status(const CertificatePathStatusCodes &cert_status)
Definition: x509path.cpp:539

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 172 of file x509path.h.

172 : 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 146 of file x509path.h.

147 { 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 131 of file x509path.h.

131 { return m_cert_path; }

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

Returns
  overall validation result code

Definition at line 141 of file x509path.h.

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

141 { return m_overall; }

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

Returns
  string representation of the validation result

Definition at line 725 of file x509path.cpp.

References result(), and status_string().

726 {
727 return status_string(result());
728 }
Botan::Path_Validation_Result::result
Certificate_Status_Code result() const
Definition: x509path.h:141
Botan::Path_Validation_Result::status_string
static const char * status_string(Certificate_Status_Code code)
Definition: x509path.cpp:730

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 730 of file x509path.cpp.

References Botan::to_string().

Referenced by result_string().

731 {
732 if(const char* s = to_string(code))
733 return s;
734
735 return "Unknown error";
736 }
Botan::to_string
std::string to_string(const secure_vector< uint8_t > &bytes)
Definition: stl_util.h:25

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

Returns
  true iff the validation was successful

Definition at line 718 of file x509path.cpp.

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

719 {
720 return (result() == Certificate_Status_Code::VERIFIED ||
721 result() == Certificate_Status_Code::OCSP_RESPONSE_GOOD ||
722 result() == Certificate_Status_Code::VALID_CRL_CHECKED);
723 }
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:141
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 700 of file x509path.cpp.

References result(), and Botan::VERIFIED.

701 {
702 if(m_cert_path.empty())
703 throw Exception("Path_Validation_Result::trust_root no path set");
704 if(result() != Certificate_Status_Code::VERIFIED)
705 throw Exception("Path_Validation_Result::trust_root meaningless with invalid status");
706
707 return *m_cert_path[m_cert_path.size()-1];
708 }
Botan::Path_Validation_Result::result
Certificate_Status_Code result() const
Definition: x509path.h:141
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 710 of file x509path.cpp.

711 {
712 std::set<std::string> hashes;
713 for(size_t i = 0; i != m_cert_path.size(); ++i)
714 hashes.insert(m_cert_path[i]->hash_used_for_signature());
715 return hashes;
716 }

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

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