Index: net/cert/cert_verify_result.cc |
diff --git a/net/cert/cert_verify_result.cc b/net/cert/cert_verify_result.cc |
index 7a1082e9f44162efb747b988f8fe7f0d593c4e3a..01b8e54d86eb2ed4242292aae2e46372de602788 100644 |
--- a/net/cert/cert_verify_result.cc |
+++ b/net/cert/cert_verify_result.cc |
@@ -17,6 +17,50 @@ CertVerifyResult::CertVerifyResult(const CertVerifyResult& other) = default; |
CertVerifyResult::~CertVerifyResult() { |
} |
+bool CertVerifyResult::Persist(base::Pickle* pickle) const { |
+ if (!pickle->WriteUInt32(cert_status) || !pickle->WriteBool(has_md2) || |
+ !pickle->WriteBool(has_md4) || !pickle->WriteBool(has_md5) || |
+ !pickle->WriteBool(has_sha1) || !pickle->WriteBool(has_sha1_leaf) || |
+ !pickle->WriteBool(is_issued_by_known_root) || |
+ !pickle->WriteBool(is_issued_by_additional_trust_anchor) || |
+ !pickle->WriteBool(common_name_fallback_used) || |
+ !pickle->WriteUInt64(public_key_hashes.size())) { |
+ return false; |
+ } |
+ for (const HashValue& value : public_key_hashes) { |
+ if (!pickle->WriteString(value.ToString())) |
+ return false; |
+ } |
+ verified_cert->Persist(pickle); |
+ return true; |
+} |
+ |
+// static |
+bool CertVerifyResult::CreateFromPickle(base::PickleIterator* iter, |
+ CertVerifyResult* result) { |
+ uint64_t public_key_hashes_size; |
+ if (!iter->ReadUInt32(&result->cert_status) || |
+ !iter->ReadBool(&result->has_md2) || !iter->ReadBool(&result->has_md4) || |
+ !iter->ReadBool(&result->has_md5) || !iter->ReadBool(&result->has_sha1) || |
+ !iter->ReadBool(&result->has_sha1_leaf) || |
+ !iter->ReadBool(&result->is_issued_by_known_root) || |
+ !iter->ReadBool(&result->is_issued_by_additional_trust_anchor) || |
+ !iter->ReadBool(&result->common_name_fallback_used) || |
+ !iter->ReadUInt64(&public_key_hashes_size)) { |
+ return false; |
+ } |
+ for (uint64_t index = 0u; index < public_key_hashes_size; ++index) { |
+ HashValue hash; |
+ std::string hash_value; |
+ if ((!iter->ReadString(&hash_value)) || (!hash.FromString(hash_value))) |
+ return false; |
+ result->public_key_hashes.push_back(hash); |
+ } |
+ result->verified_cert = X509Certificate::CreateFromPickle( |
+ iter, X509Certificate::PICKLETYPE_CERTIFICATE_CHAIN_V3); |
+ return result->verified_cert != NULL; |
+} |
+ |
void CertVerifyResult::Reset() { |
verified_cert = NULL; |
cert_status = 0; |