hierynomus / sshj

ssh, scp and sftp for java
Apache License 2.0
2.5k stars 601 forks source link

Unable to use SSHJ on Android P #540

Open shreyashpmc opened 5 years ago

shreyashpmc commented 5 years ago

Recently we have changed our Application compiled version 27 to 28 (Android P).

After that while uploading file, we are facing below issue while using method (sshClient.connect(ip, port)).

net.schmizz.sshj.transport.TransportException: no such algorithm: ECDSA for provider BC.

Can you please let me know how i can solve this issue?

jameyhicks commented 4 years ago

I ran into this problem also. Android has removed ciphers from BC that are redundant with the default security provider: https://android-developers.googleblog.com/2018/03/cryptography-changes-in-android-p.html

I have a branch of sshj that works with Android P: https://github.com/acceleratedtech/sshj

I'm willing to create a PR but I need to add an interface to control whether sshj should use the "BC" security provider or just the default providers.

shreyashpmc commented 4 years ago

@jameyhicks Just FYI if we add this library then it will work fine for newer versions as well. implementation 'com.madgag.spongycastle:prov:1.58.0.0'

Valodim commented 4 years ago

for the record, it's also possible to replace the android-shipped bouncycastle provider with the regular one, that'll also fix this issue:

    implementation "org.bouncycastle:bcprov-jdk15on:1.64"
Security.removeProvider("BC");
Security.insertProviderAt(org.bouncycastle.jce.provider.BouncyCastleProvider(), 0);
Neustradamus commented 4 years ago

Please note that Spongycastle "1.58" (dead project since several years) is a fork of Bouncy Castle. And there are CVEs not solved... It is needed to quickly move Spongycastle to Bouncy Castle.

Note: The last at this time is 1.65.