Index: net/cert/internal/path_builder.h |
diff --git a/net/cert/internal/path_builder.h b/net/cert/internal/path_builder.h |
index 177f0d6e8caceca703724bcff79dda9671529344..69784f333b0edabac2650615e04d06486fe32b81 100644 |
--- a/net/cert/internal/path_builder.h |
+++ b/net/cert/internal/path_builder.h |
@@ -11,8 +11,8 @@ |
#include "base/callback.h" |
#include "net/base/completion_callback.h" |
-#include "net/base/net_errors.h" |
#include "net/base/net_export.h" |
+#include "net/cert/internal/cert_errors.h" |
#include "net/cert/internal/completion_status.h" |
#include "net/cert/internal/parsed_certificate.h" |
#include "net/cert/internal/trust_store.h" |
@@ -64,17 +64,19 @@ class NET_EXPORT CertPathBuilder { |
ResultPath(); |
~ResultPath(); |
- // Returns true if this path was successfully verified. |
- bool is_success() const { return error == OK; } |
- |
- // The (possibly partial) certificate path. In the case of an |
- // error path.trust_anchor may be nullptr. |
+ // The (possibly partial) certificate path. Consumers must always test |
+ // |valid| before using |path|. When |!valid| path.trust_anchor may be |
+ // nullptr, and the path may be otherwise incomplete/invalid. |
CertPath path; |
- // A net error code result of attempting to verify this path. |
- // TODO(mattm): may want to have an independent result enum, which caller |
- // can map to a net error if they want. |
- int error = ERR_UNEXPECTED; |
+ // The errors/warnings from this path. Note that the list of errors is |
+ // independent of whether the path was |valid| (a valid path may |
+ // contain errors/warnings, and vice versa an invalid path may not have |
+ // logged any errors). |
+ CertErrors errors; |
+ |
+ // True if |path| is a correct verified certificate chain. |
+ bool valid = false; |
}; |
// Provides the overall result of path building. This includes the paths that |
@@ -84,21 +86,18 @@ class NET_EXPORT CertPathBuilder { |
~Result(); |
// Returns true if there was a valid path. |
- bool is_success() const { return error() == OK; } |
+ bool HasValidPath() const; |
- // Returns the net error code of the overall best result. |
- int error() const { |
- if (paths.empty()) |
- return ERR_CERT_AUTHORITY_INVALID; |
- return paths[best_result_index]->error; |
- } |
+ // Returns the ResultPath for the best valid path, or nullptr if there |
+ // was none. |
+ const ResultPath* GetBestValidPath() const; |
// List of paths that were attempted and the result for each. |
std::vector<std::unique_ptr<ResultPath>> paths; |
// Index into |paths|. Before use, |paths.empty()| must be checked. |
- // NOTE: currently the definition of "best" is fairly limited. Successful is |
- // better than unsuccessful, but otherwise nothing is guaranteed. |
+ // NOTE: currently the definition of "best" is fairly limited. Valid is |
+ // better than invalid, but otherwise nothing is guaranteed. |
size_t best_result_index = 0; |
private: |
@@ -162,7 +161,7 @@ class NET_EXPORT CertPathBuilder { |
void HandleGotNextPath(); |
CompletionStatus DoGetNextPathComplete(); |
- void AddResultPath(const CertPath& path, bool is_success); |
+ void AddResultPath(std::unique_ptr<ResultPath> result_path); |
base::Closure callback_; |