SshjConfig: use runCatching to replace exception handling
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
eded073ef2
commit
c183dd82d6
1 changed files with 2 additions and 4 deletions
|
@ -6,6 +6,7 @@ package com.zeapo.pwdstore.git.sshj
|
||||||
|
|
||||||
import com.github.ajalt.timberkt.Timber
|
import com.github.ajalt.timberkt.Timber
|
||||||
import com.github.ajalt.timberkt.d
|
import com.github.ajalt.timberkt.d
|
||||||
|
import com.github.michaelbull.result.runCatching
|
||||||
import com.hierynomus.sshj.key.KeyAlgorithms
|
import com.hierynomus.sshj.key.KeyAlgorithms
|
||||||
import com.hierynomus.sshj.transport.cipher.BlockCiphers
|
import com.hierynomus.sshj.transport.cipher.BlockCiphers
|
||||||
import com.hierynomus.sshj.transport.kex.ExtInfoClientFactory
|
import com.hierynomus.sshj.transport.kex.ExtInfoClientFactory
|
||||||
|
@ -46,10 +47,7 @@ fun setUpBouncyCastleForSshj() {
|
||||||
// Replace Android BC with Java BC, inserted at the same position.
|
// Replace Android BC with Java BC, inserted at the same position.
|
||||||
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME)
|
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME)
|
||||||
// May be needed on Android Pie+ as per https://stackoverflow.com/a/57897224/297261
|
// May be needed on Android Pie+ as per https://stackoverflow.com/a/57897224/297261
|
||||||
try {
|
runCatching { Class.forName("sun.security.jca.Providers") }
|
||||||
Class.forName("sun.security.jca.Providers")
|
|
||||||
} catch (e: ClassNotFoundException) {
|
|
||||||
}
|
|
||||||
Security.insertProviderAt(BouncyCastleProvider(), bcIndex + 1)
|
Security.insertProviderAt(BouncyCastleProvider(), bcIndex + 1)
|
||||||
}
|
}
|
||||||
d { "JCE providers: ${Security.getProviders().joinToString { "${it.name} (${it.version})" }}" }
|
d { "JCE providers: ${Security.getProviders().joinToString { "${it.name} (${it.version})" }}" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue