-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AS4 large file performance issue in 5.5.0 #201
Comments
Usage of BouncyCastleProvider as the preferred security provider (Security.insertProviderAt(new BouncyCastleProvider(), 1)) was First introduced as part of Oxalis release 4.1.7 with following code:
It was later removed as part of Oxalis 4.1.8 when some Oxalis users started facing problem because of setting BouncyCastleProvider as the preferred security provider. Refer issue #118 with comment: - "Earlier oxalis-as4 put BouncyCastle as the preferred SecurityProvider, but that introduced several problems for some of our users. Generally it is not recommended to reorder the security provider list." But if you can set BouncyCastleProvider as the preferred security provider within your integration code without any problem/interference with your other application then please go ahead and set that. I myself don't have visibility as what issue/s was faced by Oxalis users when it was first introduced as part Oxalis release 4.1.7 so can't comment further on this. But we will try to reintroduce this as part of some minor release after Oxalis 6.0.0 major release to understand the impact. |
If you know which algorithm it is, you can use something like this in As4CommonModule.init:
or generally:
|
Hello @FrodeBjerkholt, @aaron-kumar , Despite that property being set, when I run the application with the option
However, if we insert Bouncy Castle as the first provider, I then see the following:
I am not aware of anything overriding the preferred provider property on our end, and as far as I can tell, the property keeps its value throughout the execution. And in case something was overriding the property, then it wouldn't pick up the Bouncy Castle provider either when we insert it as the first one. I am a bit clueless at the moment. |
I am not working on the Oxalis project anymore, my note was just a tip for @aaron-kumar. He probably should debug to check why the SUN provider is being used for AES/GCM/NoPadding. I added the line with |
A few more insights. It seems that changing the |
There can be multiple reasons, why
It is read together with the rest of As a result, setting Security.setProperty AFTER And
It means, that setting this property should be done on the earliest phase of the application initialization. But Guice framework does not guarantee any predictable Modules loading order by design - as Modules are expected to have no side effects, and if so, the order of modules loading is considered not relevant. So it looks like this setting should be set either at java.security file or on earliest possible startup of each distribution separately or user application. Here you can see a performance comparison of SunJCE in different Java versions versus BouncyCastle 1.7 at encryption and decryption by Peppol used algorithm http://www.w3.org/2009/xmlenc11#aes128-gcm (AES/GCM/NoPadding) on different payload sizes: https://github.com/dladlk/sunjce-vs-bc-performance/blob/main/README.md And some conclusions: https://github.com/dladlk/sunjce-vs-bc-performance/blob/main/README.md#some-conclusions |
It looks like Java 21 SunJCE significantly improved performance of decryption by AES/GCM/NoPadding algorithm, so it works almost as fast as BouncyCastle (for 100 MB payload it is 1,8 second vs 1,5 second by BouncyCastle, but Java 20 did it in 11 minutes), and 5 times faster encrypts 100 MB payload (255 ms vs. 1435 ms by BouncyCastle). |
There is a performance issue when processing large files using AS4. We've been trying to process an incoming file 100 MB big and locally it was taking us 23 minutes on a fairly powerful laptop.
The issue was the security provider which somehow doesn't seem to be a BouncyCastle one as the fix in #84 promised. It looks like the fix in #104 somehow affected it.
Debugging revealed that the bottleneck was in AttachmentContentSignatureTransform at the line number 217.:
while ((numBytes = inputStream.read(buf)) != -1)
To fix it, as discovered by my colleague @javierestevez, we introduced the following code:
@PostConstruct public void init() { Security.insertProviderAt(new BouncyCastleProvider(), 1); }
to the configuration class in the spring boot project. By doing that the processing time went down to 11 seconds locally.
We are using:
Worth noting is there is no issue when using AS2.
The text was updated successfully, but these errors were encountered: