Skip to content

Commit 739eaa0

Browse files
committed
Net: fix crash on HTTP connection to ACME server.
Plain HTTP connections are prohibited by the ACME specification, so we did not have this scenario in our test automation and overlooked the regression during the pre-release code cleanup. Nonetheless, some server implementations allow such configuration and more importantly the HTTP client code should be useful as an example for other modules.
1 parent 65b35ac commit 739eaa0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/net/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl HttpClient for NgxHttpClient<'_> {
148148
.connect_to(authority.as_str(), &self.resolver, ssl)
149149
.await?;
150150

151-
if self.ssl_verify {
151+
if ssl.is_some() && self.ssl_verify {
152152
if let Err(err) = peer.verify_peer() {
153153
let _ = future::poll_fn(|cx| peer.as_mut().poll_shutdown(cx)).await;
154154
return Err(err.into());

src/net/peer_conn.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ impl PeerConnection {
219219
pub fn verify_peer(&mut self) -> Result<(), io::Error> {
220220
let c = self.connection_mut().ok_or(io::ErrorKind::NotConnected)?;
221221

222+
if c.ssl.is_null() {
223+
return Err(io::Error::new(
224+
io::ErrorKind::InvalidInput,
225+
"cannot verify peer on a non-SSL connection",
226+
));
227+
}
228+
222229
let rc = unsafe { SSL_get_verify_result((*c.ssl).connection.cast()) };
223230
if rc != (X509_V_OK as c_long) {
224231
let err = unsafe { CStr::from_ptr(X509_verify_cert_error_string(rc)) };

0 commit comments

Comments
 (0)