kezhuw commented on PR #2209:
URL: https://github.com/apache/zookeeper/pull/2209#issuecomment-2461388919

   > Isn't zcert.certstr supposed to hold the entire certificate and zcert.ca, 
zcert.key, zcert.password hold the appropriate tokens?
   
   >  zcert.certstr = strdup(cert) - this will hold the entire certificate as a 
string.
   
   
   
https://github.com/apache/zookeeper/blob/9d522642a9c78dafb7084952f9807beb205478c3/zookeeper-client/zookeeper-client-c/tests/TestReadOnlyClient.cc#L144-L158
   
   `certstr` is only used in `free(zh->fd->cert->certstr)`. I think it serves 
as a way to pass multiple ssl related parameters.
    After `zookeeper_init_ssl`, it is done and should never be used until 
`free`. If `zcert_t` is a strong encapsulated struct, than `certstr` should not 
be exposed.
   
   ```c
   zcert_t zcert_new(const char *certstr) {
       zcert_t zcert;
       zcert.certstr = strdup(cert);
       zcert.ca = strtok(zcert.certstr, ",");
       zcert.cert = strtok(NULL, ",");
       zcert.key = strtok(NULL, ",");
       zcert.passwd = strtok(NULL, ",");  
       return zcert;
   }
   
   void zcert_destroy(zert_t *zcert) {
       free(zcert->certstr);
   }
   
   const char* zcert_get_ca(zcert_t *zcert) {
       return zcert->ca;
   }
   
   // api to retrieve `cert`, `key` and `passwd` but not `certstr`.
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to