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

Function get_tls_config

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

Source from the content-addressed store, hash-verified

136}
137
138pub async fn get_tls_config(wss_proxy_options: &WssproxyOptions) -> Result<ServerConfig, Error> {
139 let max_retries = 20;
140 let mut retries = 0;
141 while retries < max_retries && !do_certificates_exist(&wss_proxy_options.certs_dir) {
142 log::debug!("Certificates incomplete. Retrying...");
143 tokio::time::sleep(Duration::from_millis(500)).await;
144 retries += 1;
145 }
146
147 if !do_certificates_exist(&wss_proxy_options.certs_dir) {
148 log::debug!("Certificates still not existing after retries. Generating...");
149 generate_certificates(&wss_proxy_options.certs_dir, &wss_proxy_options.wss_domains)?;
150 }
151
152 let certs = CertificateDer::pem_file_iter(wss_proxy_options.certs_dir.join("server.pem"))
153 .unwrap()
154 .map(|cert| cert.unwrap())
155 .collect();
156 let private_key =
157 PrivateKeyDer::from_pem_file(wss_proxy_options.certs_dir.join("server-key.pem")).unwrap();
158
159 rustls::ServerConfig::builder()
160 .with_no_client_auth()
161 .with_single_cert(certs, private_key)
162 .map_err(|e| anyhow!("{}", e))
163}

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