Skip to content

Commit 5380807

Browse files
committed
signer: Do not override the TLS SNI domain name if we're using a domain
1 parent cf2af42 commit 5380807

File tree

1 file changed

+17
-10
lines changed
  • libs/gl-client/src/signer

1 file changed

+17
-10
lines changed

libs/gl-client/src/signer/mod.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,16 @@ impl Signer {
386386
/// requests from it. The requests are then verified and processed
387387
/// using the `Hsmd`.
388388
pub async fn run_once(&self, node_uri: Uri) -> Result<(), Error> {
389-
debug!("Connecting to node at {}", node_uri);
389+
info!("Connecting to node at {}", node_uri);
390+
391+
let tls_config = if node_uri.host().unwrap_or_default().contains("blckstrm") {
392+
self.tls.inner.clone()
393+
} else {
394+
self.tls.inner.clone().domain_name("localhost")
395+
};
396+
390397
let c = Endpoint::from_shared(node_uri.to_string())?
391-
.tls_config(self.tls.inner.clone().domain_name("localhost"))?
398+
.tls_config(tls_config)?
392399
.tcp_keepalive(Some(crate::TCP_KEEPALIVE))
393400
.http2_keep_alive_interval(crate::TCP_KEEPALIVE)
394401
.keep_alive_timeout(crate::TCP_KEEPALIVE_TIMEOUT)
@@ -725,7 +732,7 @@ impl Signer {
725732
&self,
726733
scheduler_uri: String,
727734
) -> Result<SchedulerClient<tonic::transport::channel::Channel>> {
728-
debug!("Connecting to scheduler at {scheduler_uri}");
735+
info!("Connecting to scheduler at {scheduler_uri}");
729736

730737
let channel = Endpoint::from_shared(scheduler_uri.clone())?
731738
.tls_config(self.tls.inner.clone())?
@@ -740,7 +747,7 @@ impl Signer {
740747
// If it fails due to connection error, sleep and retry. Re-throw all other errors.
741748
loop {
742749
#[allow(deprecated)]
743-
let maybe_upgrade_res = scheduler
750+
let res = scheduler
744751
.maybe_upgrade(UpgradeRequest {
745752
initmsg: self.init.clone(),
746753
signer_version: self.version().to_owned(),
@@ -752,19 +759,19 @@ impl Signer {
752759
})
753760
.await;
754761

755-
if let Err(err_status) = maybe_upgrade_res {
756-
match err_status.code() {
762+
match res {
763+
Err(e) => match e.code() {
757764
Code::Unavailable => {
758765
debug!("Cannot connect to scheduler, sleeping and retrying");
759766
sleep(Duration::from_secs(3)).await;
760767
continue;
761768
}
762-
_ => {
763-
return Err(Error::Upgrade(err_status))?;
764-
}
769+
_ => Err(Error::Upgrade(e))?,
770+
},
771+
Ok(r) => {
772+
debug!("Server reports version {}", r.into_inner().old_version)
765773
}
766774
}
767-
768775
break;
769776
}
770777
Ok(scheduler)

0 commit comments

Comments
 (0)