Serialization and de-serialization of certain objects does not work as expected
See original GitHub issue[READ] Step 1: Are you in the right place?
Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:
- For general technical questions, post a question on StackOverflow with the firebase tag.
- For general Firebase discussion, use the firebase-talk google group.
- For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.
[REQUIRED] Step 2: Describe your environment
- Android Studio version: 4.1.3
- Firebase Component: inappmessaging
- Component version: 20.0.0
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
The problem
java.lang.ClassNotFoundException: com.google.android.gms.org.conscrypt.OpenSSLRSAPrivateCrtKey at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:453) at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:628) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1615) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1520) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1776) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2002) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1926) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1803) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
Without SDK of Firebase InApp Messaging (FIAM), de-serialization and serialization works as expected. Adding the firebase-inappmessaging-display dependency to the project, causes this completely separate part to throw an exception.
Relevant Code:
To generate RSA:
public static KeyPair generateRSAKeyPair() {
KeyPairGenerator keyGen = null;
KeyPair keyPair = null;
try {
keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(1024);
keyPair = keyGen.genKeyPair();
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
e.printStackTrace();
}
return keyPair;
}
To serialize:
public static byte[] serializeClientKeyPair(KeyPair clientKeyPair) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
ObjectOutputStream o;
try {
o = new ObjectOutputStream(b);
o.writeObject(clientKeyPair);
} catch (IOException e) {
e.printStackTrace();
}
byte[] res = b.toByteArray();
return res;
}
And to de-serialize:
public static KeyPair deserializeKeyPair(byte[] serializedKeyPair) {
ByteArrayInputStream bi = new ByteArrayInputStream(serializedKeyPair);
ObjectInputStream oi;
Object obj = null;
try {
oi = new ObjectInputStream(bi);
obj = oi.readObject();
} catch (StreamCorruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return ((KeyPair) obj);
}
When including FIAM SDK to the project, with an Android >=9, exception is thrown at obj = oi.readObject();
when doing the steps:
KeyPair keyPair = generateRSAKeyPair();
byte[] serialized = serializeClientKeyPair(keyPair);
KeyPair deserializedKeyPair = deserializeKeyPair(serialized);
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
hi @MarceloMaia2 ,
thanks for providing the sample app and it helps!
I was able to reproduce the issue and we are looking into it. Will keep you posted.
Let me know if you are experiencing this issue related with any other firebase SDKs other than FIAM SDK
Could you please provide a sample project with detailed steps to reproduce this issue?