-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from subbu963/main
feat: Add support for custom SSL certificates
- Loading branch information
Showing
6 changed files
with
64 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Check if a domain is provided as an argument | ||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <domain>" | ||
exit 1 | ||
fi | ||
|
||
# Retrieve and print the combined TLS certificates | ||
openssl s_client -showcerts -connect "$1":443 2>/dev/null < /dev/null | awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/{print}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::{env, io}; | ||
use std::fs::File; | ||
use std::io::BufReader; | ||
use rustls::Certificate; | ||
|
||
|
||
const ENV_CERT_FILE: &str = "SSL_CERT_FILE"; | ||
|
||
pub fn load_certs_from_env() -> io::Result<Vec<Certificate>> { | ||
let file_name = match env::var(ENV_CERT_FILE) { | ||
Ok(val) => val, | ||
Err(_) => { | ||
return io::Result::Err(io::Error::from(io::ErrorKind::NotFound)); | ||
}, | ||
}; | ||
let file = File::open(file_name)?; | ||
let mut reader = BufReader::new(file); | ||
let mut certs = rustls_pemfile::certs(&mut reader)?; | ||
Ok(certs.into_iter().map(Certificate).collect()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters