rust/bssl-tls: Expose set_tlsext_host_name to support client SNI.

Exposes the SSL_set_tlsext_host_name FFI function on TlsConnectionInHandshake, allowing clients to configure Server Name Indication (SNI) prior to handshake completion.

Change-Id: If465528cfa4a1ad286a8d50d7e492e22bde52196
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/98798
Presubmit-BoringSSL-Verified: boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Xiangfei Ding <xfding@google.com>
Commit-Queue: Xiangfei Ding <xfding@google.com>
diff --git a/rust/bssl-tls/src/connection/credentials.rs b/rust/bssl-tls/src/connection/credentials.rs
index 0d10cfa..119b30f 100644
--- a/rust/bssl-tls/src/connection/credentials.rs
+++ b/rust/bssl-tls/src/connection/credentials.rs
@@ -334,6 +334,20 @@
         });
         Ok(self)
     }
+
+    /// Set SNI extension hostname.
+    pub fn set_tlsext_host_name(&mut self, host_name: &str) -> Result<&mut Self, Error> {
+        let host_name = CString::new(host_name)
+            .map_err(|_| Error::Configuration(ConfigurationError::InvalidString))?;
+        check_lib_error!(unsafe {
+            // Safety:
+            // - the validity of the handle `self.0` is witnessed by `self`.
+            // - the host name string has been sanitised for internal NUL-bytes and NUL-terminated.
+            // - BoringSSL copies the string internally, so the pointer does not need to outlive the call.
+            bssl_sys::SSL_set_tlsext_host_name(self.0.ptr(), host_name.as_ptr())
+        });
+        Ok(self)
+    }
 }
 
 /// # Certificate verification - Certificate Chain Verification