x509_certificate_net_log_param.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/x509_certificate_net_log_param.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/values.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/x509_certificate.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace net {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)base::Value* NetLogX509CertificateCallback(const X509Certificate* certificate,
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                           NetLog::LogLevel log_level) {
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DictionaryValue* dict = new DictionaryValue();
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ListValue* certs = new ListValue();
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::vector<std::string> encoded_chain;
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  certificate->GetPEMEncodedChain(&encoded_chain);
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  for (size_t i = 0; i < encoded_chain.size(); ++i)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    certs->Append(base::Value::CreateStringValue(encoded_chain[i]));
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  dict->Set("certificates", certs);
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return dict;
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace net
28