<div dir="ltr"><div dir="ltr"><br></div><div dir="ltr">It looks to me that the function stream_ssl_set_key_and_cert() in lib/stream-ssl.c is incorrect.<div><br><font face="monospace">void<br>stream_ssl_set_key_and_cert(const char *private_key_file,<br>                            const char *certificate_file)<br>{<br>    if (update_ssl_config(&private_key, private_key_file)<br>        && update_ssl_config(&certificate, certificate_file)) {<br>        stream_ssl_set_certificate_file__(certificate_file);<br>        stream_ssl_set_private_key_file__(private_key_file);<br>    }<br>}</font><br></div><div><br></div><div>1. Say, the private key and the corresponding certificate file was replaced on the file system at T0 and T2 respectively.</div><div>2. At T1, the ovn-controller code calls update_ssl_config(private_key) and update_ssl_config(certificate_file)</div><div>2a: The first call to update_ssl_config(private_key) returns true and the file `mtime` is updated. The second call to  update_ssl_config(certificate_file) returns False</div><div>3. At T3, the ovn-controller code calls to update_ssl_config(private_key) will return False, and the modified `certifcate file` will never be picked?</div><div><br></div><div>Because of 1 - 3 above, the new files will never be picked by the ovn-controller. What we have found is that if I delete both the files and then copy over the private key and certificate files, then it works. This may be because of how we handle the ENOENT case in update_ssl_config() </div><div><br></div><div>Regards,</div><div>~Girish</div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">On Fri, Dec 11, 2020 at 9:54 AM Girish Moodalbail <<a href="mailto:gmoodalbail@gmail.com">gmoodalbail@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">In ovn-kubernetes K8s CNI project we use SSL connections between ovn-controller and OVN SB DB. Our goal is to rotate the privateKey/signedCert used by ovn-controller very often. When the rotation occurs, we want ovn-controller to redo the TLS handshake without dropping the TCP connection or without requiring ovn-controller restart.<br><br>In ovn-controller code, I see that in the main loop we call update_ssl_config(), which through a series of functions checks if SSL files are modified, and if so, calls into OpenSSL library updating the SSL context. At this point, the expectation is for ovn-controller to restart the TLS handshake so that we are using new SSL keys/certs. However, we don't see this happening.<br><br>I ran tcpdump on the ovn-controller side to check for TLS handshake packets, but I didn't see any TLS related packets. With `stream_ssl` module logging set to debug, I don't see any SSL control plane messages in ovn-controller.log.<br><br>I also created certs with expiry time of 10mins using OVS-PKI and restarted ovn-controller. My expectation was that after 10mins the SSL connection should error out with certificates already expired. I don't see<br>that is happening as well. When I run the `ovn-sbctl` command using the expired certs it obviously fails.<br><br>Looks to me that once the JSON-RPC session is created between ovn-controller and  OVN SB DB process, then nothing seems to re-trigger the TLS handshake.<br><br>Are we missing something?<br><br>Regards,<br>~Girish<br></div>
</blockquote></div></div>