OPCFoundation / UA-Java-Legacy

This repository is provided by OPC Foundation as legacy support for an Java version for OPC UA.
https://github.com/OPCFoundation/UA-.NETStandard
Other
354 stars 226 forks source link

Fixed issue #194 (RuntimeException caused by BC provider on Android) #196

Closed SimoneTinella closed 2 years ago

SimoneTinella commented 4 years ago
SimoneTinella commented 4 years ago

Yes, but the SpongyCastleUtils class is never called, and the two methods that cause the exception are only present in BouncyCastleUtilis. It would be correct to implement an interface to be extended in the two utility classes and provide a provider, but I consider it excessive for a legacy project.

jouniaro commented 4 years ago

Do you have example code that shows the case where you got the error?

SimoneTinella commented 4 years ago

I use the following code to create a cert:

1

This is a snippet of PrivKey.java from opc-ua-stack 2 PrivKey java

This is a snippet of PrivKey.java from opc-ua-stack too 3

The save method of PrivKey use BC by default, no provider is used and this cause exception on Android platform. The BouncyCastle Utils and SpongyCastle Utils classes are very similar to each other, but no common interface is implemented, furthermore the shared methods are not called from anywhere else within opc-ua-stack and the only method used is writeToPem which is part of BouncyCastleUtilis.

jouniaro commented 2 years ago

Sorry Simone, this has been pending for a long time. The stack is not actively maintained anymore, but I will apply your commit now, since it is completely valid.