Skip to content

Commit

Permalink
Merge pull request #47 from /issues/29-credentialshandler-assumes-you…
Browse files Browse the repository at this point in the history
…-have-set-up-an-ssh-key

Catch exception when no SSH key is generated
  • Loading branch information
vicr123 authored Aug 13, 2023
2 parents 8a61b50 + 4131718 commit daccb55
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 daccb55

Please sign in to comment.