V
V
Vadim Misbakh-Soloviev2014-10-24 02:01:37
Android
Vadim Misbakh-Soloviev, 2014-10-24 02:01:37

How to properly import conscrypt in an android application?

Hello.
I can't figure out how to properly import classes from conscrypt in my application.
Initially, I didn't use it at all, and until recently it worked like this:

static Func (PrivateKey privkey) throws NoSuchAlgorithmException, InvalidKeySpecException {
    if (privkey instanceof RSAPrivateCrtKey) {
<...>
      RSAPrivateCrtKey rsaPriv = (RSAPrivateCrtKey) privkey;
// использование rsaPriv.getModulus() и rsaPriv.getPublicExponent();
<...>
    } else if (privkey instanceof DSAPrivateKey) {
<...>
    } else if (privkey instanceof ECPrivateKey) {
<...>
    } else {
      throw new NoSuchAlgorithmException("Ключ не является ни RSA, ни DSA, ни EC");
    }
}

And something suddenly on Android 4.4.2, work with the RSA key broke. After almost a day of debugging, I found that in the PrivateKey runtime, privkey, in fact, has the com.android.org.conscrypt.OpenSSLRSAPrivateKey class (as well as dsa / ec classes corresponding to them from conscrypt, but it doesn’t interfere there, but here, here, hinders).
As a result, in the android runtime, with code similar to the one above, I get an error that:
java.lang.ClassCastException: com.android.org.conscrypt.OpenSSLRSAPrivateKey cannot be cast to java.security.interfaces.RSAPrivateCrtKey

and in compile time, when trying to use conscrypt, to avoid this, I cannot explain to the collector where to get conscrypt.
Because I have it (as it should) in $ANDROID_HOME/sources/<TARGET_NAME>/org/conscrypt. (i.e. in my specific case of a specific assembly of specific testing, this is /opt/android-sdk-update-manager/sources/android-19/org/conscrypt. For android-21, it also lies accordingly.
It would seem that there are no problems: you take and import, but for some reason on:
import org.conscrypt.OpenSSLRSAPrivateKey;
I get:

[javac] /home/mva/.vcs_repos/foo/Bar.java:74: error: package org.conscrypt does not exist
[javac] import org.conscrypt.OpenSSLRSAPrivateKey;

in local.properties the path to the sdk is specified as expected (however, nothing else is specified)
I tried to import com.android.org.conscrypt and in every way. And it still doesn't work.
Tell me, please, how to be and what is the best way to go? :(

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question