Bouncy castle no such method error (v1.61) and milo (v0.3.8)

simgineer :

My situation is similar to this but it is a newer version of bouncycastle so I am not sure it is the same situation and it is four years later without an accepted answer:

Bouncy castle no such method error

I am using bc with eclipse milo with an ant build: my dependencies are: bcpkix-jdk15on-1.61.jar bcprov-jdk15on-1.61.jar

When I launch our app in eclipse we are able to connect with the UA Expert test client securely without any issues. However when connecting with UA Expert to the milo opc-ua server on our deployed application on a SBC I am seeing this error:

Mar 05, 2020 6:54:48 PM org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$Task run
WARNING: Uncaught Throwable during execution.
java.lang.NoSuchMethodError: org.bouncycastle.util.Arrays.areAllZeroes([BII)Z
    at org.eclipse.milo.opcua.stack.core.util.NonceUtil.validateNonce(NonceUtil.java:183)
    at org.eclipse.milo.opcua.stack.core.util.NonceUtil.validateNonce(NonceUtil.java:153)
    at org.eclipse.milo.opcua.stack.server.transport.uasc.UascServerAsymmetricHandler.openSecureChannel(UascServerAsymmetricHandler.java:437)
    at org.eclipse.milo.opcua.stack.server.transport.uasc.UascServerAsymmetricHandler.lambda$sendOpenSecureChannelResponse$1(UascServerAsymmetricHandler.java:301)
    at org.eclipse.milo.opcua.stack.core.channel.SerializationQueue.lambda$encode$0(SerializationQueue.java:57)
    at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$Task.run(ExecutionQueue.java:119)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

we have an ant build and I believe all the classpaths are pointing to the current library.

simgineer :

We found that another jar pdfbox-all-2.0.13.jar had an older embedded version of bouncycastle in it and our ant build was unzipping those jars over the newer version of the required newer libraries. Removing the older bouncy castle classes or using a vanilla pdfbox appears to resolve the NoSuchMethod issue. Can't imagine this will be a common scenario for many others.

    <jar jarfile="${dist}/thirdparty.jar">
        <manifest>
            <!--These jars need to be at the same level as the jar created for this project-->
            <attribute name="Compiler" value="${build.compiler}"/>
        </manifest>
        <fileset dir="./src" includes="META-INF/persistence.xml" />
        <zipfileset excludes="META-INF/*.SF" src="../../../filtec-bin/packages/rhino/lib/rhino.jar" />
        <zipfileset excludes="META-INF/*.SF" src="../../../filtec-bin/packages/junit4/junit-4.12.jar" />
        ...
        <zipfileset excludes="META-INF/*.SF" src="../../../filtec-bin/packages/bouncycastle/bcpkix-jdk15on-1.61.jar" />
        <zipfileset excludes="META-INF/*.SF" src="../../../filtec-bin/packages/bouncycastle/bcprov-jdk15on-1.61.jar" />
        ...
        <zipfileset excludes="META-INF/*.SF" src="../../../filtec-bin/packages/pdfBOX/pdfbox-app-2.0.13.jar" />
        ...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=171231&siteId=1