nghttpx: Use StringRef for tls.ticket.files

This commit is contained in:
Tatsuhiro Tsujikawa 2016-10-02 22:08:51 +09:00
parent c4368a9416
commit 1037d3ad26
3 changed files with 8 additions and 8 deletions

View File

@ -151,7 +151,7 @@ bool is_secure(const StringRef &filename) {
} // namespace } // namespace
std::unique_ptr<TicketKeys> std::unique_ptr<TicketKeys>
read_tls_ticket_key_file(const std::vector<std::string> &files, read_tls_ticket_key_file(const std::vector<StringRef> &files,
const EVP_CIPHER *cipher, const EVP_MD *hmac) { const EVP_CIPHER *cipher, const EVP_MD *hmac) {
auto ticket_keys = make_unique<TicketKeys>(); auto ticket_keys = make_unique<TicketKeys>();
auto &keys = ticket_keys->keys; auto &keys = ticket_keys->keys;
@ -2451,7 +2451,7 @@ int parse_config(Config *config, int optid, const StringRef &opt,
case SHRPX_OPTID_LISTENER_DISABLE_TIMEOUT: case SHRPX_OPTID_LISTENER_DISABLE_TIMEOUT:
return parse_duration(&config->conn.listener.timeout.sleep, opt, optarg); return parse_duration(&config->conn.listener.timeout.sleep, opt, optarg);
case SHRPX_OPTID_TLS_TICKET_KEY_FILE: case SHRPX_OPTID_TLS_TICKET_KEY_FILE:
config->tls.ticket.files.push_back(optarg.str()); config->tls.ticket.files.push_back(make_string_ref(config->balloc, optarg));
return 0; return 0;
case SHRPX_OPTID_RLIMIT_NOFILE: { case SHRPX_OPTID_RLIMIT_NOFILE: {
int n; int n;

View File

@ -470,7 +470,7 @@ struct TLSConfig {
int family; int family;
bool tls; bool tls;
} memcached; } memcached;
std::vector<std::string> files; std::vector<StringRef> files;
const EVP_CIPHER *cipher; const EVP_CIPHER *cipher;
// true if --tls-ticket-key-cipher is used // true if --tls-ticket-key-cipher is used
bool cipher_given; bool cipher_given;
@ -1006,7 +1006,7 @@ FILE *open_file_for_write(const char *filename);
// expected file size. This function returns TicketKey if it // expected file size. This function returns TicketKey if it
// succeeds, or nullptr. // succeeds, or nullptr.
std::unique_ptr<TicketKeys> std::unique_ptr<TicketKeys>
read_tls_ticket_key_file(const std::vector<std::string> &files, read_tls_ticket_key_file(const std::vector<StringRef> &files,
const EVP_CIPHER *cipher, const EVP_MD *hmac); const EVP_CIPHER *cipher, const EVP_MD *hmac);
// Returns string representation of |proto|. // Returns string representation of |proto|.

View File

@ -173,8 +173,8 @@ void test_shrpx_config_read_tls_ticket_key_file(void) {
close(fd1); close(fd1);
close(fd2); close(fd2);
auto ticket_keys = auto ticket_keys = read_tls_ticket_key_file(
read_tls_ticket_key_file({file1, file2}, EVP_aes_128_cbc(), EVP_sha256()); {StringRef{file1}, StringRef{file2}}, EVP_aes_128_cbc(), EVP_sha256());
unlink(file1); unlink(file1);
unlink(file2); unlink(file2);
CU_ASSERT(ticket_keys.get() != nullptr); CU_ASSERT(ticket_keys.get() != nullptr);
@ -216,8 +216,8 @@ void test_shrpx_config_read_tls_ticket_key_file_aes_256(void) {
close(fd1); close(fd1);
close(fd2); close(fd2);
auto ticket_keys = auto ticket_keys = read_tls_ticket_key_file(
read_tls_ticket_key_file({file1, file2}, EVP_aes_256_cbc(), EVP_sha256()); {StringRef{file1}, StringRef{file2}}, EVP_aes_256_cbc(), EVP_sha256());
unlink(file1); unlink(file1);
unlink(file2); unlink(file2);
CU_ASSERT(ticket_keys.get() != nullptr); CU_ASSERT(ticket_keys.get() != nullptr);