Expose SSL_get_error
This commit is contained in:
parent
20f9991c18
commit
0f5731b1d8
|
|
@ -13,6 +13,9 @@ use crate::ssl::MidHandshakeSslStream;
|
||||||
pub struct ErrorCode(c_int);
|
pub struct ErrorCode(c_int);
|
||||||
|
|
||||||
impl ErrorCode {
|
impl ErrorCode {
|
||||||
|
/// No error.
|
||||||
|
pub const NONE: ErrorCode = ErrorCode(ffi::SSL_ERROR_NONE);
|
||||||
|
|
||||||
/// The SSL session has been closed.
|
/// The SSL session has been closed.
|
||||||
pub const ZERO_RETURN: ErrorCode = ErrorCode(ffi::SSL_ERROR_ZERO_RETURN);
|
pub const ZERO_RETURN: ErrorCode = ErrorCode(ffi::SSL_ERROR_ZERO_RETURN);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2635,10 +2635,6 @@ impl SslRef {
|
||||||
unsafe { ffi::SSL_write(self.as_ptr(), buf.as_ptr() as *const c_void, len) }
|
unsafe { ffi::SSL_write(self.as_ptr(), buf.as_ptr() as *const c_void, len) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_error(&self, ret: c_int) -> ErrorCode {
|
|
||||||
unsafe { ErrorCode::from_raw(ffi::SSL_get_error(self.as_ptr(), ret)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "kx-safe-default")]
|
#[cfg(feature = "kx-safe-default")]
|
||||||
fn set_curves_list(&mut self, curves: &str) -> Result<(), ErrorStack> {
|
fn set_curves_list(&mut self, curves: &str) -> Result<(), ErrorStack> {
|
||||||
let curves = CString::new(curves).unwrap();
|
let curves = CString::new(curves).unwrap();
|
||||||
|
|
@ -2683,6 +2679,15 @@ impl SslRef {
|
||||||
.expect("invalid default server curves list");
|
.expect("invalid default server curves list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an `ErrorCode` value for the most recent operation on this `SslRef`.
|
||||||
|
///
|
||||||
|
/// This corresponds to [`SSL_get_error`].
|
||||||
|
///
|
||||||
|
/// [`SSL_get_error`]: https://github.com/google/boringssl/blob/master/include/openssl/ssl.h#L475
|
||||||
|
pub fn error_code(&self, ret: c_int) -> ErrorCode {
|
||||||
|
unsafe { ErrorCode::from_raw(ffi::SSL_get_error(self.as_ptr(), ret)) }
|
||||||
|
}
|
||||||
|
|
||||||
/// Like [`SslContextBuilder::set_verify`].
|
/// Like [`SslContextBuilder::set_verify`].
|
||||||
///
|
///
|
||||||
/// This corresponds to [`SSL_set_verify`].
|
/// This corresponds to [`SSL_set_verify`].
|
||||||
|
|
@ -3762,7 +3767,7 @@ impl<S> SslStream<S> {
|
||||||
fn make_error(&mut self, ret: c_int) -> Error {
|
fn make_error(&mut self, ret: c_int) -> Error {
|
||||||
self.check_panic();
|
self.check_panic();
|
||||||
|
|
||||||
let code = self.ssl.get_error(ret);
|
let code = self.ssl.error_code(ret);
|
||||||
|
|
||||||
let cause = match code {
|
let cause = match code {
|
||||||
ErrorCode::SSL => Some(InnerError::Ssl(ErrorStack::get())),
|
ErrorCode::SSL => Some(InnerError::Ssl(ErrorStack::get())),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue