Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1024#discussion_r82046288
  
    --- Diff: iocore/net/SSLConfig.cc ---
    @@ -243,6 +245,21 @@ SSLConfigParams::initialize()
       ats_free(ssl_server_ca_cert_filename);
       ats_free(CACertRelativePath);
     
    +  REC_ReadConfigStringAlloc(ticket_key_filename, 
"proxy.config.ssl.server.ticket_key.filename");
    +  int ticket_key_len;
    +  ats_scoped_str 
ticket_key_path(Layout::relative_to(this->serverCertPathOnly, 
this->ticket_key_filename));
    +  ats_scoped_str ticket_key_data;
    +  if (ticket_key_filename != NULL) {
    +    ticket_key_data = readIntoBuffer(ticket_key_path, __func__, 
&ticket_key_len);
    +  } else {
    +    // Generate a random ticket key
    +    ticket_key_len  = 48;
    +    ticket_key_data = (char *)ats_malloc(ticket_key_len);
    +    char *tmp_ptr   = ticket_key_data;
    +    RAND_bytes(reinterpret_cast<unsigned char *>(tmp_ptr), ticket_key_len);
    +  }
    --- End diff --
    
    Simplify to this:
    ```C
    if (ticket_key_filename) {
      int len;
      ats_scoped_str path(Layout::relative_to(this->serverCertPathOnly, 
this->ticket_key_filename));
      ats_scoped_str data = readIntoBuffer(path, __func__, &len);
    
      // XXX error checking?
    
      default_global_keyblock = ticket_block_XXX(data, len);
    } else {
        ssl_ticket_key_t key;
        RAND_bytes(&key, sizeof(key));
    
       default_global_keyblock = ticket_block_XXX(&key, sizeof(key));
    }
    
    ```
    
    *or*
    
    Add additional ticket block APIs:
    ```C
     ssl_ticket_key_block *ticket_block_alloc_random(unsigned count);
     ssl_ticket_key_block *ticket_block_read(const char *path);
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to