MCPcopy Create free account
hub / github.com/ElementsProject/lightning / get_tls_config

Function get_tls_config

plugins/wss-proxy-plugin/src/certs.rs:126–151  ·  view source on GitHub ↗
(wss_proxy_options: &WssproxyOptions)

Source from the content-addressed store, hash-verified

124}
125
126pub async fn get_tls_config(wss_proxy_options: &WssproxyOptions) -> Result<ServerConfig, Error> {
127 let max_retries = 20;
128 let mut retries = 0;
129 while retries < max_retries && !do_certificates_exist(&wss_proxy_options.certs_dir) {
130 log::debug!("Certificates incomplete. Retrying...");
131 tokio::time::sleep(Duration::from_millis(500)).await;
132 retries += 1;
133 }
134
135 if !do_certificates_exist(&wss_proxy_options.certs_dir) {
136 log::debug!("Certificates still not existing after retries. Generating...");
137 generate_certificates(&wss_proxy_options.certs_dir, &wss_proxy_options.wss_domains)?;
138 }
139
140 let certs = CertificateDer::pem_file_iter(wss_proxy_options.certs_dir.join("server.pem"))
141 .unwrap()
142 .map(|cert| cert.unwrap())
143 .collect();
144 let private_key =
145 PrivateKeyDer::from_pem_file(wss_proxy_options.certs_dir.join("server-key.pem")).unwrap();
146
147 rustls::ServerConfig::builder()
148 .with_no_client_auth()
149 .with_single_cert(certs, private_key)
150 .map_err(|e| anyhow!("{}", e))
151}

Callers 1

mainFunction · 0.85

Calls 5

mapMethod · 0.80
joinMethod · 0.80
do_certificates_existFunction · 0.70
generate_certificatesFunction · 0.70
unwrapMethod · 0.45

Tested by

no test coverage detected