Skip to content

Commit

Permalink
server: adjust sni_hostname() -> server_name() (#298)
Browse files Browse the repository at this point in the history
This follows the upstream change in Rustls to prefer `server_name` over
`sni_hostname`.
  • Loading branch information
cpu authored and jsha committed Mar 29, 2023
1 parent 3c21a74 commit 43a9ba6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/rustls.h
Original file line number Diff line number Diff line change
Expand Up @@ -1487,15 +1487,15 @@ rustls_result rustls_server_connection_new(const struct rustls_server_config *co
struct rustls_connection **conn_out);

/**
* Copy the SNI hostname to `buf` which can hold up to `count` bytes,
* and the length of that hostname in `out_n`. The string is stored in UTF-8
* with no terminating NUL byte.
* Copy the server name from the server name indication (SNI) extension to `buf` which can
* hold up to `count` bytes, and the length of that server name in `out_n`. The string is
* stored in UTF-8 with no terminating NUL byte.
* Returns RUSTLS_RESULT_INSUFFICIENT_SIZE if the SNI hostname is longer than `count`.
* Returns Ok with *out_n == 0 if there is no SNI hostname available on this connection
* because it hasn't been processed yet, or because the client did not send SNI.
* <https://docs.rs/rustls/0.20.0/rustls/server/struct.ServerConnection.html#method.sni_hostname>
* <https://docs.rs/rustls/0.21.0/rustls/server/struct.ServerConnection.html#method.server_name>
*/
rustls_result rustls_server_connection_get_sni_hostname(const struct rustls_connection *conn,
rustls_result rustls_server_connection_get_server_name(const struct rustls_connection *conn,
uint8_t *buf,
size_t count,
size_t *out_n);
Expand Down
12 changes: 6 additions & 6 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,15 @@ impl rustls_server_config {
}
}

/// Copy the SNI hostname to `buf` which can hold up to `count` bytes,
/// and the length of that hostname in `out_n`. The string is stored in UTF-8
/// with no terminating NUL byte.
/// Copy the server name from the server name indication (SNI) extension to `buf` which can
/// hold up to `count` bytes, and the length of that server name in `out_n`. The string is
/// stored in UTF-8 with no terminating NUL byte.
/// Returns RUSTLS_RESULT_INSUFFICIENT_SIZE if the SNI hostname is longer than `count`.
/// Returns Ok with *out_n == 0 if there is no SNI hostname available on this connection
/// because it hasn't been processed yet, or because the client did not send SNI.
/// <https://docs.rs/rustls/0.20.0/rustls/server/struct.ServerConnection.html#method.sni_hostname>
/// <https://docs.rs/rustls/0.21.0/rustls/server/struct.ServerConnection.html#method.server_name>
#[no_mangle]
pub extern "C" fn rustls_server_connection_get_sni_hostname(
pub extern "C" fn rustls_server_connection_get_server_name(
conn: *const rustls_connection,
buf: *mut u8,
count: size_t,
Expand All @@ -375,7 +375,7 @@ pub extern "C" fn rustls_server_connection_get_sni_hostname(
Some(s) => s,
_ => return rustls_result::InvalidParameter,
};
let sni_hostname = match server_connection.sni_hostname() {
let sni_hostname = match server_connection.server_name() {
Some(sni_hostname) => sni_hostname,
None => {
unsafe {
Expand Down

0 comments on commit 43a9ba6

Please sign in to comment.