Skip to content

Commit 1782d07

Browse files
committed
Ensure SSL_get_error works for accept-state SSLs
1 parent b3f481d commit 1782d07

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

src/lib.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,27 +1510,26 @@ impl Ssl {
15101510
}
15111511

15121512
fn get_error(&mut self) -> c_int {
1513-
match self.conn_mut() {
1514-
Some(conn) => {
1515-
if let Err(e) = conn.process_new_packets() {
1516-
error::Error::from_rustls(e).raise();
1517-
return SSL_ERROR_SSL;
1518-
}
1519-
1520-
let want = self.want();
1513+
// protocol errors take precedence
1514+
if let Some(conn) = self.conn_mut() {
1515+
if let Err(e) = conn.process_new_packets() {
1516+
error::Error::from_rustls(e).raise();
1517+
return SSL_ERROR_SSL;
1518+
}
1519+
}
15211520

1522-
if let Some(bio) = self.bio.as_ref() {
1523-
if want.write && bio.write_would_block() {
1524-
return SSL_ERROR_WANT_WRITE;
1525-
} else if want.read && bio.read_would_block() {
1526-
return SSL_ERROR_WANT_READ;
1527-
}
1528-
}
1521+
// io errors remain
1522+
let want = self.want();
15291523

1530-
SSL_ERROR_NONE
1524+
if let Some(bio) = self.bio.as_ref() {
1525+
if want.write && bio.write_would_block() {
1526+
return SSL_ERROR_WANT_WRITE;
1527+
} else if want.read && bio.read_would_block() {
1528+
return SSL_ERROR_WANT_READ;
15311529
}
1532-
None => SSL_ERROR_SSL,
15331530
}
1531+
1532+
SSL_ERROR_NONE
15341533
}
15351534

15361535
fn load_verify_certs(ctx: &SslContext) -> Result<OwnedX509Store, error::Error> {

0 commit comments

Comments
 (0)