Merge pull request #11468 from thingsboard/fix/vc-ssh-error

VC: fix error message when using https url with private key authentication
This commit is contained in:
Viacheslav Klimov 2024-08-22 13:09:30 +03:00 committed by GitHub
commit efabd86ad6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -467,6 +467,9 @@ public class GitRepository {
if (RepositoryAuthMethod.USERNAME_PASSWORD.equals(settings.getAuthMethod())) {
credentialsProvider = newCredentialsProvider(settings.getUsername(), settings.getPassword());
} else if (RepositoryAuthMethod.PRIVATE_KEY.equals(settings.getAuthMethod())) {
if (StringUtils.startsWith(settings.getRepositoryUri(), "https://")) {
throw new IllegalArgumentException("Invalid URI format for private key authentication");
}
sshSessionFactory = newSshdSessionFactory(settings.getPrivateKey(), settings.getPrivateKeyPassword(), directory);
}
return new AuthHandler(credentialsProvider, sshSessionFactory);