aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-10-28 07:04:29 +0530
committerGitHub <noreply@github.com>2021-10-28 07:04:29 +0530
commit22ed045ea70658038f0c2b65ce5bc68f56660f26 (patch)
treed8d691bbe5426d62f8989f83936f9360384738af /app
parentaac74ae4515aa1d746f46287029441f5a945c98e (diff)
Upgrade dependencies (#1526)
* gradle: upgrade all dependencies * github: replace gradle-cache-action with official gradle-build-action * github: update wrapper-validation-action
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjSessionFactory.kt30
1 files changed, 19 insertions, 11 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjSessionFactory.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjSessionFactory.kt
index 79438bcc..50c146cc 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjSessionFactory.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjSessionFactory.kt
@@ -13,6 +13,8 @@ import java.io.File
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
+import java.security.PublicKey
+import java.util.Collections
import java.util.concurrent.TimeUnit
import kotlin.coroutines.Continuation
import kotlin.coroutines.suspendCoroutine
@@ -88,19 +90,25 @@ class SshjSessionFactory(private val authMethod: SshAuthMethod, private val host
private fun makeTofuHostKeyVerifier(hostKeyFile: File): HostKeyVerifier {
if (!hostKeyFile.exists()) {
- return HostKeyVerifier { _, _, key ->
- val digest =
- runCatching { SecurityUtils.getMessageDigest("SHA-256") }.getOrElse { e ->
- throw SSHRuntimeException(e)
+ return object : HostKeyVerifier {
+ override fun verify(hostname: String?, port: Int, key: PublicKey?): Boolean {
+ val digest =
+ runCatching { SecurityUtils.getMessageDigest("SHA-256") }.getOrElse { e ->
+ throw SSHRuntimeException(e)
+ }
+ digest.update(PlainBuffer().putPublicKey(key).compactData)
+ val digestData = digest.digest()
+ val hostKeyEntry = "SHA256:${Base64.encodeToString(digestData, Base64.NO_WRAP)}"
+ logcat(SshjSessionFactory::class.java.simpleName) {
+ "Trusting host key on first use: $hostKeyEntry"
}
- digest.update(PlainBuffer().putPublicKey(key).compactData)
- val digestData = digest.digest()
- val hostKeyEntry = "SHA256:${Base64.encodeToString(digestData, Base64.NO_WRAP)}"
- logcat(SshjSessionFactory::class.java.simpleName) {
- "Trusting host key on first use: $hostKeyEntry"
+ hostKeyFile.writeText(hostKeyEntry)
+ return true
+ }
+
+ override fun findExistingAlgorithms(hostname: String?, port: Int): MutableList<String> {
+ return Collections.emptyList()
}
- hostKeyFile.writeText(hostKeyEntry)
- true
}
} else {
val hostKeyEntry = hostKeyFile.readText()