mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-15 03:01:36 +00:00
Some checks failed
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
use log::info;
|
|
use rcgen::generate_simple_self_signed;
|
|
use sha2::{Sha256, Digest};
|
|
|
|
pub struct Certificate {
|
|
pub certificate: Vec<u8>,
|
|
pub private_key: Vec<u8>,
|
|
pub fingerprint: String,
|
|
}
|
|
|
|
pub fn generate_certificate() -> Certificate {
|
|
|
|
let subject_alt_names = vec!["localhost".to_string()];
|
|
let certificate_data = generate_simple_self_signed(subject_alt_names).unwrap();
|
|
let certificate_binary_data = certificate_data.cert.der().to_vec();
|
|
|
|
let certificate_fingerprint = Sha256::digest(certificate_binary_data).to_vec();
|
|
let certificate_fingerprint = certificate_fingerprint.iter().fold(String::new(), |mut result, byte| {
|
|
result.push_str(&format!("{:02x}", byte));
|
|
result
|
|
});
|
|
|
|
let certificate_fingerprint = certificate_fingerprint.to_uppercase();
|
|
|
|
info!("Certificate fingerprint: '{certificate_fingerprint}'.");
|
|
|
|
Certificate {
|
|
certificate: certificate_data.cert.pem().as_bytes().to_vec(),
|
|
private_key: certificate_data.signing_key.serialize_pem().as_bytes().to_vec(),
|
|
fingerprint: certificate_fingerprint.clone()
|
|
}
|
|
} |