Skip to content

Commit 42bc63e

Browse files
committed
ca+tools: configurable ca forwarding hint and ca-server interface improvement
Change-Id: I95cc6b2fb195f7c3625f14a4f8856abcf65022d9
1 parent 5926d8b commit 42bc63e

File tree

9 files changed

+35
-14
lines changed

9 files changed

+35
-14
lines changed

ca.conf.sample

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"redirect-to": [
2020
{
2121
"ca-prefix": "/ndn/edu/ucla",
22-
"certificate": "Bv0BNQcwCANuZG4IA2VkdQgEdWNsYQgDS0VZCAgAdGt6D7S2VAgEc2VsZggJ/QAAAX5lZMOiFAkYAQIZBAA27oAVWzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABOKmvwHmK5t+MhMPgft4qmKC7YF9I6UM/o7GFa4BjZQknsqLvxdW2zIAF+iPPHJV0eVAijX6bYrQobuomiWZAY0WUBsBAxwhBx8IA25kbggDZWR1CAR1Y2xhCANLRVkICAB0a3oPtLZU/QD9Jv0A/g8xOTcwMDEwMVQwMDAwMDD9AP8PMjA0MjAxMTJUMDAxNjQ5F0cwRQIgBF/HS0j1DMo/dIILv/6IMUmMAhVtS3m97YgS8tsBhC0CIQCgEm0e6KoBCyV6PiueN9YW9zSSkdg8MLCxsyduP8tRsQ=="
22+
"certificate": "Bv0BNQcwCANuZG4IA2VkdQgEdWNsYQgDS0VZCAgAdGt6D7S2VAgEc2VsZggJ/QAAAX5lZMOiFAkYAQIZBAA27oAVWzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABOKmvwHmK5t+MhMPgft4qmKC7YF9I6UM/o7GFa4BjZQknsqLvxdW2zIAF+iPPHJV0eVAijX6bYrQobuomiWZAY0WUBsBAxwhBx8IA25kbggDZWR1CAR1Y2xhCANLRVkICAB0a3oPtLZU/QD9Jv0A/g8xOTcwMDEwMVQwMDAwMDD9AP8PMjA0MjAxMTJUMDAxNjQ5F0cwRQIgBF/HS0j1DMo/dIILv/6IMUmMAhVtS3m97YgS8tsBhC0CIQCgEm0e6KoBCyV6PiueN9YW9zSSkdg8MLCxsyduP8tRsQ==",
23+
"policy-type": "email",
24+
"policy-param": "g.ucla.edu"
2325
},
2426
{
2527
"ca-prefix": "/ndn/edu/ucla/cs",

src/ca-module.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,8 @@ CaModule::onChallenge(const Interest& request)
441441
requestState->status = Status::SUCCESS;
442442
m_storage->deleteRequest(requestState->requestId);
443443

444-
payload = challengetlv::encodeDataContent(*requestState, issuedCert.getName());
444+
payload = challengetlv::encodeDataContent(*requestState, issuedCert.getName(),
445+
m_config.caProfile.forwardingHint);
445446
NDN_LOG_TRACE("Challenge succeeded. Certificate has been issued: " << issuedCert.getName());
446447
}
447448
else if (requestState->requestType == RequestType::REVOKE) {

src/detail/ca-profile.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ CaProfile::fromJson(const JsonSection& json)
3535
if (profile.caPrefix.empty()) {
3636
NDN_THROW(std::runtime_error("Cannot parse ca-prefix from the config file"));
3737
}
38+
// Forwarding hint
39+
profile.forwardingHint = Name(json.get(CONFIG_FORWARDING_HINT, ""));
40+
if (profile.forwardingHint.empty()) {
41+
profile.forwardingHint = Name(profile.caPrefix).append("CA");
42+
}
3843
// CA info
3944
profile.caInfo = json.get(CONFIG_CA_INFO, "");
4045
// CA max validity period

src/detail/ca-profile.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const std::string CONFIG_PROBE_PARAMETER = "probe-parameter-key";
3737
const std::string CONFIG_SUPPORTED_CHALLENGES = "supported-challenges";
3838
const std::string CONFIG_CHALLENGE = "challenge";
3939
const std::string CONFIG_CERTIFICATE = "certificate";
40+
const std::string CONFIG_FORWARDING_HINT = "forwarding-hint";
4041
const std::string CONFIG_REDIRECTION = "redirect-to";
4142
const std::string CONFIG_NAME_ASSIGNMENT = "name-assignment";
4243
const std::string CONFIG_REDIRECTION_POLICY_TYPE = "policy-type";
@@ -64,6 +65,10 @@ class CaProfile
6465
* @brief CA Name prefix (without /CA suffix).
6566
*/
6667
Name caPrefix;
68+
/**
69+
* @brief Forwarding hint for requesters to retrieve issued certificates.
70+
*/
71+
Name forwardingHint;
6772
/**
6873
* @brief CA Information.
6974
*/

src/detail/challenge-encoder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
/*
3-
* Copyright (c) 2017-2022, Regents of the University of California.
3+
* Copyright (c) 2017-2024, Regents of the University of California.
44
*
55
* This file is part of ndncert, a certificate management system based on NDN.
66
*
@@ -23,7 +23,7 @@
2323
namespace ndncert::challengetlv {
2424

2525
Block
26-
encodeDataContent(ca::RequestState& request, const Name& issuedCertName)
26+
encodeDataContent(ca::RequestState& request, const Name& issuedCertName, const Name& forwardingHint)
2727
{
2828
Block response(tlv::EncryptedPayload);
2929
response.push_back(ndn::makeNonNegativeIntegerBlock(tlv::Status, static_cast<uint64_t>(request.status)));
@@ -41,7 +41,7 @@ encodeDataContent(ca::RequestState& request, const Name& issuedCertName)
4141
}
4242
if (!issuedCertName.empty()) {
4343
response.push_back(makeNestedBlock(tlv::IssuedCertName, issuedCertName));
44-
response.push_back(makeNestedBlock(ndn::tlv::ForwardingHint, Name(request.caPrefix).append("CA")));
44+
response.push_back(makeNestedBlock(ndn::tlv::ForwardingHint, forwardingHint));
4545
}
4646
response.encode();
4747

src/detail/challenge-encoder.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
/*
3-
* Copyright (c) 2017-2022, Regents of the University of California.
3+
* Copyright (c) 2017-2024, Regents of the University of California.
44
*
55
* This file is part of ndncert, a certificate management system based on NDN.
66
*
@@ -27,7 +27,8 @@
2727
namespace ndncert::challengetlv {
2828

2929
Block
30-
encodeDataContent(ca::RequestState& request, const Name& issuedCertName = Name());
30+
encodeDataContent(ca::RequestState& request, const Name& issuedCertName = Name(),
31+
const Name& forwardingHint = Name());
3132

3233
void
3334
decodeDataContent(const Block& contentBlock, requester::Request& state);

tests/unit-tests/config-files/config-ca-1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"ca-prefix": "/ndn",
3+
"forwarding-hint": "/repo",
34
"ca-info": "ndn testbed ca",
45
"max-validity-period": "864000",
56
"max-suffix-length": 3,

tests/unit-tests/configuration.t.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
/*
3-
* Copyright (c) 2017-2022, Regents of the University of California.
3+
* Copyright (c) 2017-2024, Regents of the University of California.
44
*
55
* This file is part of ndncert, a certificate management system based on NDN.
66
*
@@ -33,6 +33,7 @@ BOOST_AUTO_TEST_CASE(CaConfigFile)
3333
ca::CaConfig config;
3434
config.load("tests/unit-tests/config-files/config-ca-1");
3535
BOOST_CHECK_EQUAL(config.caProfile.caPrefix, "/ndn");
36+
BOOST_CHECK_EQUAL(config.caProfile.forwardingHint, "/repo");
3637
BOOST_CHECK_EQUAL(config.caProfile.caInfo, "ndn testbed ca");
3738
BOOST_CHECK_EQUAL(config.caProfile.maxValidityPeriod, time::seconds(864000));
3839
BOOST_CHECK_EQUAL(*config.caProfile.maxSuffixLength, 3);
@@ -43,6 +44,7 @@ BOOST_AUTO_TEST_CASE(CaConfigFile)
4344

4445
config.load("tests/unit-tests/config-files/config-ca-2");
4546
BOOST_CHECK_EQUAL(config.caProfile.caPrefix, "/ndn");
47+
BOOST_CHECK_EQUAL(config.caProfile.forwardingHint, "/ndn/CA");
4648
BOOST_CHECK_EQUAL(config.caProfile.caInfo, "missing max validity period, max suffix length, and probe");
4749
BOOST_CHECK_EQUAL(config.caProfile.maxValidityPeriod, time::seconds(86400));
4850
BOOST_CHECK(!config.caProfile.maxSuffixLength.has_value());

tools/ndncert-ca-server.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
/*
3-
* Copyright (c) 2017-2023, Regents of the University of California.
3+
* Copyright (c) 2017-2024, Regents of the University of California.
44
*
55
* This file is part of ndncert, a certificate management system based on NDN.
66
*
@@ -37,7 +37,7 @@ namespace ndncert::ca {
3737

3838
static ndn::Face face;
3939
static ndn::KeyChain keyChain;
40-
static std::string repoHost = "localhost";
40+
static std::string repoHost;
4141
static std::string repoPort = "7376";
4242
constexpr size_t MAX_CACHED_CERT_NUM = 100;
4343

@@ -48,7 +48,7 @@ writeDataToRepo(const Data& data)
4848
requestStream.expires_after(std::chrono::seconds(5));
4949
requestStream.connect(repoHost, repoPort);
5050
if (!requestStream) {
51-
std::cerr << "ERROR: Cannot publish the certificate to repo-ng"
51+
std::cerr << "ERROR: Cannot publish the certificate to repo"
5252
<< " (" << requestStream.error().message() << ")" << std::endl;
5353
return false;
5454
}
@@ -92,9 +92,9 @@ main(int argc, char* argv[])
9292
optsDesc.add_options()
9393
("help,h", "print this help message and exit")
9494
("config-file,c", po::value<std::string>(&configFilePath)->default_value(configFilePath), "path to configuration file")
95-
("repo-output,r", po::bool_switch(&wantRepoOut), "when enabled, all issued certificates will be published to repo-ng")
96-
("repo-host,H", po::value<std::string>(&repoHost)->default_value(repoHost), "repo-ng host")
97-
("repo-port,P", po::value<std::string>(&repoPort)->default_value(repoPort), "repo-ng port");
95+
("repo-host,H", po::value<std::string>(&repoHost)->default_value(repoHost),
96+
"repo host (if empty or unspecified, issued certificates will not be published to a repo)")
97+
("repo-port,P", po::value<std::string>(&repoPort)->default_value(repoPort), "repo port");
9898

9999
po::variables_map vm;
100100
try {
@@ -117,6 +117,10 @@ main(int argc, char* argv[])
117117
return 0;
118118
}
119119

120+
if (!repoHost.empty()) {
121+
wantRepoOut = true;
122+
}
123+
120124
CaModule ca(face, keyChain, configFilePath);
121125
std::deque<Data> cachedCertificates;
122126
auto profileData = ca.getCaProfileData();

0 commit comments

Comments
 (0)