Skip to content

Commit

Permalink
Catch exception when no SSH key is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
vicr123 committed Aug 13, 2023
1 parent 8a61b50 commit 4131718
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ public RemoteCommunicationService(ParlanceContext dbContext)
public Credentials CredentialsHandler(string url, string usernameFromUrl, SupportedCredentialTypes types)
{
//TODO: Check number of retries
var key = _dbContext.SshKeys.First();

return new SshKeyMemoryCredentials
try
{
Username = usernameFromUrl,
PublicKey = key.SshKeyContents,
PrivateKey = key.SshPrivateKeyContents
};
var key = _dbContext.SshKeys.First();

return new SshKeyMemoryCredentials
{
Username = usernameFromUrl,
PublicKey = key.SshKeyContents,
PrivateKey = key.SshPrivateKeyContents
};
}
catch (InvalidOperationException)
{
return new DefaultCredentials();
}
}

public bool CertificateCheckHandler(Certificate certificate, bool valid, string host)
Expand Down

0 comments on commit 4131718

Please sign in to comment.