Skip to content

Commit 745b200

Browse files
authored
Merge pull request #2155 from zh-jq/update-boringssl
enable x509 verify and groups list for boringssl
2 parents 2ed3c60 + f0100bf commit 745b200

File tree

5 files changed

+57
-57
lines changed

5 files changed

+57
-57
lines changed

openssl/src/ssl/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ use crate::ssl::error::InnerError;
7979
use crate::stack::{Stack, StackRef, Stackable};
8080
use crate::util::{ForeignTypeExt, ForeignTypeRefExt};
8181
use crate::x509::store::{X509Store, X509StoreBuilderRef, X509StoreRef};
82-
#[cfg(any(ossl102, libressl261))]
82+
#[cfg(any(ossl102, boringssl, libressl261))]
8383
use crate::x509::verify::X509VerifyParamRef;
8484
use crate::x509::{X509Name, X509Ref, X509StoreContextRef, X509VerifyResult, X509};
8585
use crate::{cvt, cvt_n, cvt_p, init};
@@ -1307,18 +1307,18 @@ impl SslContextBuilder {
13071307

13081308
/// Returns a reference to the X509 verification configuration.
13091309
///
1310-
/// Requires OpenSSL 1.0.2 or newer.
1310+
/// Requires BoringSSL or OpenSSL 1.0.2 or newer.
13111311
#[corresponds(SSL_CTX_get0_param)]
1312-
#[cfg(any(ossl102, libressl261))]
1312+
#[cfg(any(ossl102, boringssl, libressl261))]
13131313
pub fn verify_param(&self) -> &X509VerifyParamRef {
13141314
unsafe { X509VerifyParamRef::from_ptr(ffi::SSL_CTX_get0_param(self.as_ptr())) }
13151315
}
13161316

13171317
/// Returns a mutable reference to the X509 verification configuration.
13181318
///
1319-
/// Requires OpenSSL 1.0.2 or newer.
1319+
/// Requires BoringSSL or OpenSSL 1.0.2 or newer.
13201320
#[corresponds(SSL_CTX_get0_param)]
1321-
#[cfg(any(ossl102, libressl261))]
1321+
#[cfg(any(ossl102, boringssl, libressl261))]
13221322
pub fn verify_param_mut(&mut self) -> &mut X509VerifyParamRef {
13231323
unsafe { X509VerifyParamRef::from_ptr_mut(ffi::SSL_CTX_get0_param(self.as_ptr())) }
13241324
}
@@ -1719,9 +1719,9 @@ impl SslContextBuilder {
17191719

17201720
/// Sets the context's supported elliptic curve groups.
17211721
///
1722-
/// Requires OpenSSL 1.1.1 or LibreSSL 2.5.1 or newer.
1722+
/// Requires BoringSSL or OpenSSL 1.1.1 or LibreSSL 2.5.1 or newer.
17231723
#[corresponds(SSL_CTX_set1_groups_list)]
1724-
#[cfg(any(ossl111, libressl251))]
1724+
#[cfg(any(ossl111, boringssl, libressl251))]
17251725
pub fn set_groups_list(&mut self, groups: &str) -> Result<(), ErrorStack> {
17261726
let groups = CString::new(groups).unwrap();
17271727
unsafe {
@@ -2769,9 +2769,9 @@ impl SslRef {
27692769

27702770
/// Returns a mutable reference to the X509 verification configuration.
27712771
///
2772-
/// Requires OpenSSL 1.0.2 or newer.
2772+
/// Requires BoringSSL or OpenSSL 1.0.2 or newer.
27732773
#[corresponds(SSL_get0_param)]
2774-
#[cfg(any(ossl102, libressl261))]
2774+
#[cfg(any(ossl102, boringssl, libressl261))]
27752775
pub fn param_mut(&mut self) -> &mut X509VerifyParamRef {
27762776
unsafe { X509VerifyParamRef::from_ptr_mut(ffi::SSL_get0_param(self.as_ptr())) }
27772777
}

openssl/src/x509/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use crate::util::{ForeignTypeExt, ForeignTypeRefExt};
4141
use crate::{cvt, cvt_n, cvt_p, cvt_p_const};
4242
use openssl_macros::corresponds;
4343

44-
#[cfg(any(ossl102, libressl261))]
44+
#[cfg(any(ossl102, boringssl, libressl261))]
4545
pub mod verify;
4646

4747
pub mod extension;

openssl/src/x509/store.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use crate::ssl::SslFiletype;
5252
use crate::stack::Stack;
5353
use crate::stack::StackRef;
5454
use crate::util::ForeignTypeRefExt;
55-
#[cfg(any(ossl102, libressl261))]
55+
#[cfg(any(ossl102, boringssl, libressl261))]
5656
use crate::x509::verify::{X509VerifyFlags, X509VerifyParamRef};
5757
use crate::x509::{X509Object, X509PurposeId, X509};
5858
use crate::{cvt, cvt_p};
@@ -123,7 +123,7 @@ impl X509StoreBuilderRef {
123123

124124
/// Sets certificate chain validation related flags.
125125
#[corresponds(X509_STORE_set_flags)]
126-
#[cfg(any(ossl102, libressl261))]
126+
#[cfg(any(ossl102, boringssl, libressl261))]
127127
pub fn set_flags(&mut self, flags: X509VerifyFlags) -> Result<(), ErrorStack> {
128128
unsafe { cvt(ffi::X509_STORE_set_flags(self.as_ptr(), flags.bits())).map(|_| ()) }
129129
}
@@ -137,7 +137,7 @@ impl X509StoreBuilderRef {
137137

138138
/// Sets certificate chain validation related parameters.
139139
#[corresponds[X509_STORE_set1_param]]
140-
#[cfg(any(ossl102, libressl261))]
140+
#[cfg(any(ossl102, boringssl, libressl261))]
141141
pub fn set_param(&mut self, param: &X509VerifyParamRef) -> Result<(), ErrorStack> {
142142
unsafe { cvt(ffi::X509_STORE_set1_param(self.as_ptr(), param.as_ptr())).map(|_| ()) }
143143
}

openssl/src/x509/tests.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ use crate::x509::extension::{
1616
#[cfg(not(boringssl))]
1717
use crate::x509::store::X509Lookup;
1818
use crate::x509::store::X509StoreBuilder;
19-
#[cfg(any(ossl102, libressl261))]
19+
#[cfg(any(ossl102, boringssl, libressl261))]
2020
use crate::x509::verify::{X509VerifyFlags, X509VerifyParam};
21-
#[cfg(ossl102)]
21+
#[cfg(any(ossl102, boringssl))]
2222
use crate::x509::X509PurposeId;
23-
#[cfg(any(ossl102, libressl261))]
23+
#[cfg(any(ossl102, boringssl, libressl261))]
2424
use crate::x509::X509PurposeRef;
2525
#[cfg(ossl110)]
2626
use crate::x509::{CrlReason, X509Builder};
@@ -31,7 +31,7 @@ use crate::x509::{
3131
#[cfg(ossl110)]
3232
use foreign_types::ForeignType;
3333
use hex::{self, FromHex};
34-
#[cfg(any(ossl102, libressl261))]
34+
#[cfg(any(ossl102, boringssl, libressl261))]
3535
use libc::time_t;
3636

3737
use super::{AuthorityInformationAccess, CertificateIssuer, ReasonCode};
@@ -557,7 +557,7 @@ fn test_verify_fails() {
557557
}
558558

559559
#[test]
560-
#[cfg(any(ossl102, libressl261))]
560+
#[cfg(any(ossl102, boringssl, libressl261))]
561561
fn test_verify_fails_with_crl_flag_set_and_no_crl() {
562562
let cert = include_bytes!("../../test/cert.pem");
563563
let cert = X509::from_pem(cert).unwrap();
@@ -584,7 +584,7 @@ fn test_verify_fails_with_crl_flag_set_and_no_crl() {
584584
}
585585

586586
#[test]
587-
#[cfg(any(ossl102, libressl261))]
587+
#[cfg(any(ossl102, boringssl, libressl261))]
588588
fn test_verify_cert_with_purpose() {
589589
let cert = include_bytes!("../../test/cert.pem");
590590
let cert = X509::from_pem(cert).unwrap();
@@ -611,7 +611,7 @@ fn test_verify_cert_with_purpose() {
611611
}
612612

613613
#[test]
614-
#[cfg(any(ossl102, libressl261))]
614+
#[cfg(any(ossl102, boringssl, libressl261))]
615615
fn test_verify_cert_with_wrong_purpose_fails() {
616616
let cert = include_bytes!("../../test/cert.pem");
617617
let cert = X509::from_pem(cert).unwrap();
@@ -846,7 +846,7 @@ fn test_name_to_owned() {
846846
}
847847

848848
#[test]
849-
#[cfg(any(ossl102, libressl261))]
849+
#[cfg(any(ossl102, boringssl, libressl261))]
850850
fn test_verify_param_set_time_fails_verification() {
851851
const TEST_T_2030: time_t = 1893456000;
852852

@@ -877,7 +877,7 @@ fn test_verify_param_set_time_fails_verification() {
877877
}
878878

879879
#[test]
880-
#[cfg(any(ossl102, libressl261))]
880+
#[cfg(any(ossl102, boringssl, libressl261))]
881881
fn test_verify_param_set_time() {
882882
const TEST_T_2020: time_t = 1577836800;
883883

@@ -901,7 +901,7 @@ fn test_verify_param_set_time() {
901901
}
902902

903903
#[test]
904-
#[cfg(any(ossl102, libressl261))]
904+
#[cfg(any(ossl102, boringssl, libressl261))]
905905
fn test_verify_param_set_depth() {
906906
let cert = include_bytes!("../../test/leaf.pem");
907907
let cert = X509::from_pem(cert).unwrap();
@@ -928,7 +928,7 @@ fn test_verify_param_set_depth() {
928928
}
929929

930930
#[test]
931-
#[cfg(any(ossl102, libressl261))]
931+
#[cfg(any(ossl102, boringssl, libressl261))]
932932
#[allow(clippy::bool_to_int_with_if)]
933933
fn test_verify_param_set_depth_fails_verification() {
934934
let cert = include_bytes!("../../test/leaf.pem");
@@ -1003,7 +1003,7 @@ fn test_verify_param_auth_level() {
10031003
}
10041004

10051005
#[test]
1006-
#[cfg(ossl102)]
1006+
#[cfg(any(ossl102, boringssl))]
10071007
fn test_set_purpose() {
10081008
let cert = include_bytes!("../../test/leaf.pem");
10091009
let cert = X509::from_pem(cert).unwrap();
@@ -1028,7 +1028,7 @@ fn test_set_purpose() {
10281028
}
10291029

10301030
#[test]
1031-
#[cfg(ossl102)]
1031+
#[cfg(any(ossl102, boringssl))]
10321032
fn test_set_purpose_fails_verification() {
10331033
let cert = include_bytes!("../../test/leaf.pem");
10341034
let cert = X509::from_pem(cert).unwrap();

openssl/src/x509/verify.rs

+31-31
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use libc::{c_int, c_uint, c_ulong, time_t};
44
use std::net::IpAddr;
55

66
use crate::error::ErrorStack;
7-
#[cfg(ossl102)]
7+
#[cfg(any(ossl102, boringssl))]
88
use crate::x509::X509PurposeId;
99
use crate::{cvt, cvt_p};
1010
use openssl_macros::corresponds;
@@ -14,17 +14,17 @@ bitflags! {
1414
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1515
#[repr(transparent)]
1616
pub struct X509CheckFlags: c_uint {
17-
const ALWAYS_CHECK_SUBJECT = ffi::X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT;
18-
const NO_WILDCARDS = ffi::X509_CHECK_FLAG_NO_WILDCARDS;
19-
const NO_PARTIAL_WILDCARDS = ffi::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS;
20-
const MULTI_LABEL_WILDCARDS = ffi::X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS;
21-
const SINGLE_LABEL_SUBDOMAINS = ffi::X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS;
17+
const ALWAYS_CHECK_SUBJECT = ffi::X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT as _;
18+
const NO_WILDCARDS = ffi::X509_CHECK_FLAG_NO_WILDCARDS as _;
19+
const NO_PARTIAL_WILDCARDS = ffi::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS as _;
20+
const MULTI_LABEL_WILDCARDS = ffi::X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS as _;
21+
const SINGLE_LABEL_SUBDOMAINS = ffi::X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS as _;
2222
/// Requires OpenSSL 1.1.0 or newer.
2323
#[cfg(any(ossl110))]
2424
const NEVER_CHECK_SUBJECT = ffi::X509_CHECK_FLAG_NEVER_CHECK_SUBJECT;
2525

2626
#[deprecated(since = "0.10.6", note = "renamed to NO_WILDCARDS")]
27-
const FLAG_NO_WILDCARDS = ffi::X509_CHECK_FLAG_NO_WILDCARDS;
27+
const FLAG_NO_WILDCARDS = ffi::X509_CHECK_FLAG_NO_WILDCARDS as _;
2828
}
2929
}
3030

@@ -33,35 +33,35 @@ bitflags! {
3333
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3434
#[repr(transparent)]
3535
pub struct X509VerifyFlags: c_ulong {
36-
const CB_ISSUER_CHECK = ffi::X509_V_FLAG_CB_ISSUER_CHECK;
37-
const USE_CHECK_TIME = ffi::X509_V_FLAG_USE_CHECK_TIME;
38-
const CRL_CHECK = ffi::X509_V_FLAG_CRL_CHECK;
39-
const CRL_CHECK_ALL = ffi::X509_V_FLAG_CRL_CHECK_ALL;
40-
const IGNORE_CRITICAL = ffi::X509_V_FLAG_IGNORE_CRITICAL;
41-
const X509_STRICT = ffi::X509_V_FLAG_X509_STRICT;
42-
const ALLOW_PROXY_CERTS = ffi::X509_V_FLAG_ALLOW_PROXY_CERTS;
43-
const POLICY_CHECK = ffi::X509_V_FLAG_POLICY_CHECK;
44-
const EXPLICIT_POLICY = ffi::X509_V_FLAG_EXPLICIT_POLICY;
45-
const INHIBIT_ANY = ffi::X509_V_FLAG_INHIBIT_ANY;
46-
const INHIBIT_MAP = ffi::X509_V_FLAG_INHIBIT_MAP;
47-
const NOTIFY_POLICY = ffi::X509_V_FLAG_NOTIFY_POLICY;
48-
const EXTENDED_CRL_SUPPORT = ffi::X509_V_FLAG_EXTENDED_CRL_SUPPORT;
49-
const USE_DELTAS = ffi::X509_V_FLAG_USE_DELTAS;
50-
const CHECK_SS_SIGNATURE = ffi::X509_V_FLAG_CHECK_SS_SIGNATURE;
51-
#[cfg(ossl102)]
52-
const TRUSTED_FIRST = ffi::X509_V_FLAG_TRUSTED_FIRST;
36+
const CB_ISSUER_CHECK = ffi::X509_V_FLAG_CB_ISSUER_CHECK as _;
37+
const USE_CHECK_TIME = ffi::X509_V_FLAG_USE_CHECK_TIME as _;
38+
const CRL_CHECK = ffi::X509_V_FLAG_CRL_CHECK as _;
39+
const CRL_CHECK_ALL = ffi::X509_V_FLAG_CRL_CHECK_ALL as _;
40+
const IGNORE_CRITICAL = ffi::X509_V_FLAG_IGNORE_CRITICAL as _;
41+
const X509_STRICT = ffi::X509_V_FLAG_X509_STRICT as _;
42+
const ALLOW_PROXY_CERTS = ffi::X509_V_FLAG_ALLOW_PROXY_CERTS as _;
43+
const POLICY_CHECK = ffi::X509_V_FLAG_POLICY_CHECK as _;
44+
const EXPLICIT_POLICY = ffi::X509_V_FLAG_EXPLICIT_POLICY as _;
45+
const INHIBIT_ANY = ffi::X509_V_FLAG_INHIBIT_ANY as _;
46+
const INHIBIT_MAP = ffi::X509_V_FLAG_INHIBIT_MAP as _;
47+
const NOTIFY_POLICY = ffi::X509_V_FLAG_NOTIFY_POLICY as _;
48+
const EXTENDED_CRL_SUPPORT = ffi::X509_V_FLAG_EXTENDED_CRL_SUPPORT as _;
49+
const USE_DELTAS = ffi::X509_V_FLAG_USE_DELTAS as _;
50+
const CHECK_SS_SIGNATURE = ffi::X509_V_FLAG_CHECK_SS_SIGNATURE as _;
51+
#[cfg(any(ossl102, boringssl))]
52+
const TRUSTED_FIRST = ffi::X509_V_FLAG_TRUSTED_FIRST as _;
5353
#[cfg(ossl102)]
5454
const SUITEB_128_LOS_ONLY = ffi::X509_V_FLAG_SUITEB_128_LOS_ONLY;
5555
#[cfg(ossl102)]
5656
const SUITEB_192_LOS = ffi::X509_V_FLAG_SUITEB_128_LOS;
5757
#[cfg(ossl102)]
5858
const SUITEB_128_LOS = ffi::X509_V_FLAG_SUITEB_192_LOS;
59-
#[cfg(ossl102)]
60-
const PARTIAL_CHAIN = ffi::X509_V_FLAG_PARTIAL_CHAIN;
61-
#[cfg(ossl110)]
62-
const NO_ALT_CHAINS = ffi::X509_V_FLAG_NO_ALT_CHAINS;
63-
#[cfg(ossl110)]
64-
const NO_CHECK_TIME = ffi::X509_V_FLAG_NO_CHECK_TIME;
59+
#[cfg(any(ossl102, boringssl))]
60+
const PARTIAL_CHAIN = ffi::X509_V_FLAG_PARTIAL_CHAIN as _;
61+
#[cfg(any(ossl110, boringssl))]
62+
const NO_ALT_CHAINS = ffi::X509_V_FLAG_NO_ALT_CHAINS as _;
63+
#[cfg(any(ossl110, boringssl))]
64+
const NO_CHECK_TIME = ffi::X509_V_FLAG_NO_CHECK_TIME as _;
6565
}
6666
}
6767

@@ -208,7 +208,7 @@ impl X509VerifyParamRef {
208208

209209
/// Sets the verification purpose
210210
#[corresponds(X509_VERIFY_PARAM_set_purpose)]
211-
#[cfg(ossl102)]
211+
#[cfg(any(ossl102, boringssl))]
212212
pub fn set_purpose(&mut self, purpose: X509PurposeId) -> Result<(), ErrorStack> {
213213
unsafe { cvt(ffi::X509_VERIFY_PARAM_set_purpose(self.as_ptr(), purpose.0)).map(|_| ()) }
214214
}

0 commit comments

Comments
 (0)