diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-08-11 16:22:28 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-08-11 16:22:28 +0100 |
| commit | 45df8ab7b0a2f54ad3f1ccad5a9a6fae31999675 (patch) | |
| tree | ea0dcc12a878058de61466a73544ae5d1a44dda1 /src/certificate_chain.cc | |
| parent | 3956d410a1fce4fe3b02cd7c52d9717e29371f3b (diff) | |
More stringstream removal.
Diffstat (limited to 'src/certificate_chain.cc')
| -rw-r--r-- | src/certificate_chain.cc | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc index 0cf9ee06..df68cb9f 100644 --- a/src/certificate_chain.cc +++ b/src/certificate_chain.cc @@ -106,9 +106,7 @@ command (string cmd) int const code = WEXITSTATUS (r); #endif if (code) { - locked_stringstream s; - s << "error " << code << " in " << cmd << " within " << boost::filesystem::current_path(); - throw dcp::MiscError (s.str()); + throw dcp::MiscError (String::compose ("error %1 in %2 within %3", code, cmd, boost::filesystem::current_path().string())); } } @@ -123,9 +121,7 @@ public_key_digest (boost::filesystem::path private_key, boost::filesystem::path boost::filesystem::path public_name = private_key.string() + ".public"; /* Create the public key from the private key */ - locked_stringstream s; - s << "\"" << openssl.string() << "\" rsa -outform PEM -pubout -in " << private_key.string() << " -out " << public_name.string (); - command (s.str().c_str ()); + command (String::compose("\"%1\" rsa -outform PEM -pubout -in %2 -out %3", openssl.string(), private_key.string(), public_name.string ())); /* Read in the public key from the file */ @@ -220,11 +216,13 @@ CertificateChain::CertificateChain ( "/dnQualifier=" + public_key_digest ("ca.key", openssl); { - locked_stringstream c; - c << quoted_openssl - << " req -new -x509 -sha256 -config ca.cnf -days 3650 -set_serial 5" - << " -subj \"" << ca_subject << "\" -key ca.key -outform PEM -out ca.self-signed.pem"; - command (c.str().c_str()); + command ( + String::compose ( + "%1 req -new -x509 -sha256 -config ca.cnf -days 3650 -set_serial 5" + " -subj \"%2\" -key ca.key -outform PEM -out ca.self-signed.pem", + quoted_openssl, ca_subject + ) + ); } command (quoted_openssl + " genrsa -out intermediate.key 2048"); @@ -251,13 +249,14 @@ CertificateChain::CertificateChain ( "/dnQualifier=" + public_key_digest ("intermediate.key", openssl); { - locked_stringstream s; - s << quoted_openssl - << " req -new -config intermediate.cnf -days 3649 -subj \"" << inter_subject << "\" -key intermediate.key -out intermediate.csr"; - command (s.str().c_str()); + command ( + String::compose ( + "%1 req -new -config intermediate.cnf -days 3649 -subj \"%2\" -key intermediate.key -out intermediate.csr", + quoted_openssl, inter_subject + ) + ); } - command ( quoted_openssl + " x509 -req -sha256 -days 3649 -CA ca.self-signed.pem -CAkey ca.key -set_serial 6" @@ -288,9 +287,12 @@ CertificateChain::CertificateChain ( "/dnQualifier=" + public_key_digest ("leaf.key", openssl); { - locked_stringstream s; - s << quoted_openssl << " req -new -config leaf.cnf -days 3648 -subj \"" << leaf_subject << "\" -key leaf.key -outform PEM -out leaf.csr"; - command (s.str().c_str()); + command ( + String::compose ( + "%1 req -new -config leaf.cnf -days 3648 -subj \"%2\" -key leaf.key -outform PEM -out leaf.csr", + quoted_openssl, leaf_subject + ) + ); } command ( |
