Skip to content

Class cast exception in Notification Class #108

@iyashsoni

Description

@iyashsoni

I am using library version 5.0.2

I get the following error org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey cannot be cast to org.bouncycastle.jce.interfaces.ECPublicKey when I try and instantiate the Notification class at runtime.

In my setup, as we are bundling the entire server in a war file, due to re-bundling, signature breaks for bouncycastle libs, So I'm using a custom class loader to accommodate Subscription class cryptographic operations.

But in the Notification Class, there is a cast as below:

    public Notification(String endpoint, PublicKey userPublicKey, byte[] userAuth, byte[] payload, int ttl) {
        this(endpoint, (ECPublicKey)userPublicKey, userAuth, payload, ttl);
    }

This is from org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey to org.bouncycastle.jce.interfaces.ECPublicKey, which is a valid cast. But for some reason it gives me error at run time saying it is invalid.

We have added compile dependency in our project pom to avoid build issues due to missing bouncycastle lib, as we are only loading it through reflection.

@martijndwars, Can you help please?

Please let me know if you need additional info.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions