Skip to content

Commit

Permalink
fix(ci): use rustls over openssl to cross build
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuttymoon committed Sep 12, 2023
1 parent de2958f commit 32e3ca7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 35 deletions.
47 changes: 24 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions crates/ash_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ enum-display-derive = "0.1.1"
serde_json = "1.0.96"
strum = { version = "0.24", features = ["derive"] }
chrono = { version = "0.4.24", features = ["clock"] }
openssl = "0.10.54"
rustls = "0.21.7"
rustls-pemfile = "1.0.3"

[dev-dependencies]
serial_test = "2.0.0"
tempfile = "3.3.0"

[target.aarch64-unknown-linux-gnu.dependencies]
openssl = { version = "0.10.54", features = ["vendored"] }
13 changes: 5 additions & 8 deletions crates/ash_sdk/src/avalanche/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use avalanche_types::{
ids::node::Id as NodeId,
jsonrpc::info::{GetNodeVersionResult, UptimeResult, VmVersions},
};
use openssl::x509::X509;
use rustls_pemfile::certs;
use serde::{Deserialize, Serialize};
use std::net::{IpAddr, Ipv4Addr};

Expand Down Expand Up @@ -201,11 +201,9 @@ pub fn node_id_from_cert_der(cert_bytes: &[u8]) -> Result<NodeId, AshError> {

/// Compute the node ID from the PEM-encoded X509 certificate string
pub fn node_id_from_cert_pem(cert_str: &str) -> Result<NodeId, AshError> {
let cert = X509::from_pem(cert_str.as_bytes())
.map_err(|e| AvalancheNodeError::InvalidCertificate(e.to_string()))?;
let cert_der = cert
.to_der()
.map_err(|e| AvalancheNodeError::InvalidCertificate(e.to_string()))?;
let cert_der = certs(&mut cert_str.as_bytes())
.map_err(|e| AvalancheNodeError::InvalidCertificate(e.to_string()))?
.remove(0);

let node_id = node_id_from_cert_der(&cert_der)?;

Expand Down Expand Up @@ -280,8 +278,7 @@ mod tests {
#[test]
fn test_node_id_from_cert_der() {
let cert_pem = fs::read_to_string("tests/certs/validator01.crt").unwrap();
let cert = X509::from_pem(cert_pem.as_bytes()).unwrap();
let cert_der = cert.to_der().unwrap();
let cert_der = certs(&mut cert_pem.as_bytes()).unwrap().remove(0);

let node_id = node_id_from_cert_der(&cert_der).unwrap();

Expand Down

0 comments on commit 32e3ca7

Please sign in to comment.