Skip to content

Commit 51f4276

Browse files
committed
Removed openssl from default features, added openssl version check
1 parent 68a9676 commit 51f4276

6 files changed

Lines changed: 25 additions & 21 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ time = ["dep:chrono", "dep:chrono-tz"]
4646
uuid = ["dep:uuid"]
4747
urlquery = ["dep:url"]
4848
yaml = ["serde_yaml"]
49-
jwt = []
50-
jwt_backend_openssl = ["openssl"]
49+
jwt_openssl = ["openssl"]
5150
full-opa = [
5251
"base64",
5352
"base64url",
@@ -66,9 +65,7 @@ full-opa = [
6665
"time",
6766
"uuid",
6867
"urlquery",
69-
"yaml",
70-
"jwt",
71-
"jwt_backend_openssl"
68+
"yaml"
7269
#"rego-extensions"
7370
]
7471

@@ -146,6 +143,7 @@ num_cpus = "1.16"
146143

147144
[build-dependencies]
148145
anyhow = "1.0"
146+
openssl = { version = "0.10.73", optional = true}
149147

150148
[profile.release]
151149
debug = true

build.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ fn main() -> Result<()> {
2626
println!("cargo:rustc-env=GIT_HASH={git_hash}");
2727
}
2828

29+
// Verify OpenSSL version
30+
#[cfg(feature = "jwt_openssl")]
31+
{
32+
use openssl::version;
33+
// Minimal OpenSSL version that meets FIPS certification
34+
let min_ver_num = 0x30000000i64;
35+
let ver = version::version();
36+
let ver_num = version::number();
37+
if !ver.starts_with("OpenSSL") || ver_num < min_ver_num {
38+
panic!(
39+
"FATAL: OpenSSL version must be 3.0.0 or higher, found version: {}",
40+
ver
41+
);
42+
}
43+
}
44+
2945
// Rerun only if build.rs changes.
3046
println!("cargo:rerun-if-changed=build.rs");
3147
Ok(())

src/builtins/jwt/backends/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
#[cfg(feature = "jwt_backend_openssl")]
4+
#[cfg(feature = "jwt_openssl")]
55
pub mod openssl;

src/builtins/jwt/toolkit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
#[cfg(feature = "jwt_backend_openssl")]
4+
#[cfg(feature = "jwt_openssl")]
55
use crate::builtins::jwt::backends::openssl::OpensslBackend;
66

7-
#[cfg(feature = "jwt_backend_openssl")]
7+
#[cfg(feature = "jwt_openssl")]
88
pub type JwtBackend = OpensslBackend;

src/builtins/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ mod utils;
4949
#[cfg(feature = "uuid")]
5050
mod uuid;
5151

52-
#[cfg(feature = "jwt")]
52+
#[cfg(feature = "jwt_openssl")]
5353
mod jwt;
54-
#[cfg(feature = "jwt")]
54+
#[cfg(feature = "jwt_openssl")]
5555
mod token_verification;
5656

5757
#[cfg(feature = "opa-testutil")]
@@ -114,7 +114,7 @@ lazy_static! {
114114
tracing::register(&mut m);
115115
units::register(&mut m);
116116

117-
#[cfg(feature = "jwt")]
117+
#[cfg(feature = "jwt_openssl")]
118118
token_verification::register(&mut m);
119119

120120
#[cfg(feature = "opa-testutil")]

tests/opa.passing

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ v0/jsonfilteridempotent
4343
v0/jsonremove
4444
v0/jsonremoveidempotent
4545
v0/jsonschema
46-
v0/jwtbuiltins
47-
v0/jwtverifyhs256
48-
v0/jwtverifyhs384
49-
v0/jwtverifyhs512
50-
v0/jwtverifyrsa
5146
v0/negation
5247
v0/nestedreferences
5348
v0/netcidrisvalid
@@ -155,11 +150,6 @@ v1/jsonfilteridempotent
155150
v1/jsonremove
156151
v1/jsonremoveidempotent
157152
v1/jsonschema
158-
v1/jwtbuiltins
159-
v1/jwtverifyhs256
160-
v1/jwtverifyhs384
161-
v1/jwtverifyhs512
162-
v1/jwtverifyrsa
163153
v1/negation
164154
v1/nestedreferences
165155
v1/netcidrcontains

0 commit comments

Comments
 (0)