diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 22:25:45 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-19 22:25:45 +0000 |
commit | c2c27f7ff0cddd7015fed3cbbe31b124549b1763 (patch) | |
tree | 25461deaa78f074ae5fc7c97d7213d3f415ea7c0 | |
parent | cd87adfe0ae90a9d387f8a232349bff98893abdc (diff) | |
download | chromium_src-c2c27f7ff0cddd7015fed3cbbe31b124549b1763.zip chromium_src-c2c27f7ff0cddd7015fed3cbbe31b124549b1763.tar.gz chromium_src-c2c27f7ff0cddd7015fed3cbbe31b124549b1763.tar.bz2 |
net: add a tool to dump CRL sets.
This tool is used in the build pipeline to verify that a candidate CRL set can
be correctly parsed by the Chromium code.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8977001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115028 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/net.gyp | 13 | ||||
-rw-r--r-- | net/tools/crl_set_dump/crl_set_dump.cc | 74 |
2 files changed, 86 insertions, 1 deletions
diff --git a/net/net.gyp b/net/net.gyp index 8f399d7..acbbe6c 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -1530,7 +1530,18 @@ ], 'sources': [ 'tools/dnssec_chain_verify/dnssec_chain_verify.cc', - ] + ], + }, + { + 'target_name': 'crl_set_dump', + 'type': 'executable', + 'dependencies': [ + 'net', + '../base/base.gyp:base', + ], + 'sources': [ + 'tools/crl_set_dump/crl_set_dump.cc', + ], }, { 'target_name': 'ssl_false_start_blacklist_process', diff --git a/net/tools/crl_set_dump/crl_set_dump.cc b/net/tools/crl_set_dump/crl_set_dump.cc new file mode 100644 index 0000000..ffd08ceb --- /dev/null +++ b/net/tools/crl_set_dump/crl_set_dump.cc @@ -0,0 +1,74 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This utility can dump the contents of CRL set, optionally augmented with a +// delta CRL set. + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> + +#include <string> + +#include "base/at_exit.h" +#include "base/file_util.h" +#include "base/memory/ref_counted.h" +#include "base/string_number_conversions.h" +#include "net/base/crl_set.h" + +static int Usage(const char* argv0) { + fprintf(stderr, "Usage: %s <crl-set file> [<delta file>]\n", argv0); + return 1; +} + +int main(int argc, char** argv) { + base::AtExitManager at_exit_manager; + + if (argc < 2) + return Usage(argv[0]); + + FilePath crl_set_filename, delta_filename; + + if (argc != 2 && argc != 3) + return Usage(argv[0]); + + crl_set_filename = FilePath::FromUTF8Unsafe(argv[1]); + if (argc == 3) + delta_filename = FilePath::FromUTF8Unsafe(argv[2]); + + std::string crl_set_bytes, delta_bytes; + if (!file_util::ReadFileToString(crl_set_filename, &crl_set_bytes)) + return 1; + if (!delta_filename.empty() && + !file_util::ReadFileToString(delta_filename, &delta_bytes)) { + return 1; + } + + scoped_refptr<net::CRLSet> crl_set, final_crl_set; + if (!net::CRLSet::Parse(crl_set_bytes, &crl_set)) { + fprintf(stderr, "Failed to parse CRLSet\n"); + return 1; + } + + if (!delta_bytes.empty()) { + if (!crl_set->ApplyDelta(delta_bytes, &final_crl_set)) { + fprintf(stderr, "Failed to apply delta to CRLSet\n"); + return 1; + } + } else { + final_crl_set = crl_set; + } + + const net::CRLSet::CRLList& crls = crl_set->crls(); + for (net::CRLSet::CRLList::const_iterator i = crls.begin(); i != crls.end(); + i++) { + printf("%s\n", base::HexEncode(i->first.data(), i->first.size()).c_str()); + for (std::vector<std::string>::const_iterator j = i->second.begin(); + j != i->second.end(); j++) { + printf(" %s\n", base::HexEncode(j->data(), j->size()).c_str()); + } + } + + return 0; +} |