Sending RSA Public Key over Sockets

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Sending RSA Public Key over Sockets

    Hello,

    I'm creating a Client-Server Chat Application. They are communicating over Sockets. The Server and the Android Client are written in Kotlin.
    Now to my question. When the Client is opened it generetes a RSA KeyPair. When the Client wants to log in on the Server it sends it's own public Key to the Server for encryption. Here my code for building the KeyPair:

    Quellcode

    1. object Keys {
    2. var publicKeyServer: PublicKey? = null
    3. private val keyPair = buildKeyPair()
    4. val privateKey: PrivateKey = keyPair.private
    5. val publicKey: PublicKey = keyPair.public
    6. private fun buildKeyPair(): KeyPair {
    7. val keyPairGenerator = KeyPairGenerator.getInstance("RSA")
    8. keyPairGenerator.initialize(2048)
    9. return keyPairGenerator.genKeyPair()
    10. }
    11. }
    Alles anzeigen
    The Public Key is send in a MessageObject. Now when reading the Object from the ObjectInputStream I'm getting a ClassNotFoundException:

    java.lang.ClassNotFoundException: com.android.org.conscrypt.OpenSSLRSAPublicKey
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:686)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1866)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1749)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2040)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1571)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2285)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2209)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2067)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1571)
    at java.io.ObjectInputStream.readUnshared(ObjectInputStream.java:521)
    at server.ClientThread.run(ClientThread.kt:67)

    I can't figure out why the Server is looking for the Class OpenSSLRSAPublicKey. I don't use it anywhere. Is conscrypt Androids Security Provider?
    I would appreciate your help.

    Thanks in advance

    Ludtwigk