Hi,
Iam trying to establish a secure connection with a server written in C++
and a client written in java. iam using Bouncy Castle provider as
suggested in the book "Proffesional Java Security". The way it works is
the server generates a public key and sends over to the client and then
the client sends a symmetric key using the servers public key. I first
wrote a client and server using java and this scheme works just fine. but
when i wrote a C++ server (which uses the microsofts base cryptographic
provider) and a java client (which is what the actual scenario is going to
be for our product) i get the following exception when i get the servers
public key in bytes and try to generate a java object out of it.
java.security.spec.InvalidKeySpecException: java.lang.ClassCastException:
org.bouncycastle.asn1.DERObjectIdentifier
at
org.bouncycastle.jce.provider.JDKKeyFactory$RSA.engineGeneratePublic
(JDKKeyFactory.java:218)
at java.security.KeyFactory.generatePublic(Unknown Source)
at CVSecureConnection.getServersPublicKey
CVSecureConnection.java:143)
at CVSecureConnection.establishSecureConnection
(CVSecureConnection.java:46)
at SSLClient.establishConnection(SSLClient.java:20)
at SSLClient.main(SSLClient.java:8)
The size of the public key sent over by the server is 84 bytes. The server
first sends me the size of the key as a long followed by the actual
exported key as a stream of bytes.
Thanks.