我有一个读取4个xml文件的camel路由并使用camel crypto对它们进行加密。我有另一条路线来获取这些加密文件,解密并将它们保存到文件系统。它工作得非常好。
但是,我要求在单个camel路由中解密和压缩这些文件。我无法做到这一点。任何帮助将不胜感激。
Caused by: java.io.IOException: Attempted to read a '1347093252' byte initialization vector from inputStream but only '6016' bytes were retrieved
at org.apache.camel.converter.crypto.CryptoDataFormat.getInlinedInitializationVector(CryptoDataFormat.java:193)
WARN AggregateProcessor - Error processing aggregated exchange. Exchange[Message: [Body is file based: /tmp/camel-tmp-342373/camel4393278949787760082.zip]]. Caused by: [java.io.IOException - Error reading initialization vector from encrypted stream]
java.io.IOException: Error reading initialization vector from encrypted stream
at org.apache.camel.converter.crypto.CryptoDataFormat.getInlinedInitializationVector(CryptoDataFormat.java:197)
at org.apache.camel.converter.crypto.CryptoDataFormat.unmarshal(CryptoDataFormat.java:152)
at org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:65)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
<camel:crypto id="cry" keyRef="secretKey" algorithm="AES/CBC/PKCS5Padding" initVectorRef="iv" inline="true"
shouldAppendHMAC="false" />
<camel:route>
<camel:from uri="file:/opt/vipin/abc/dec?include=.*.xml&noop=true" />
<camel:marshal ref="cry" />
<camel:to uri="file:/opt/vipin/abc/enc?doneFileName=test.done" />
</camel:route>
<camel:route>
<camel:from uri="file:/opt/vipin/abc/enc?
include=.*.xml&noop=true&doneFileName=test.done" />
<camel:aggregate strategyRef="zipAggregationStrategy"
completionFromBatchConsumer="true" completionSize="4">
<camel:correlationExpression>
<camel:constant>true</camel:constant>
</camel:correlationExpression>
<camel:convertBodyTo type="java.io.File" />
<camel:unmarshal ref="cry" />
<camel:to uri="file:/opt/vipin/abc/dec?fileName=abc.zip" />
</camel:aggregate>
</camel:route>
答案 0 :(得分:1)
我目前正在维护您过去使用的应用程序。偶尔我还会看到上面提到的错误。当我用谷歌搜索错误时,这是我在网上发现的唯一一篇文章:)小世界!
我认为当使用不同的Java Keystore来解密文件时会导致问题。例如我在使用证书Cert1的Keystore 1的JVM中加密了文件。然后尝试在具有密钥库2和具有相同名称的不同证书的不同JVM中解密它:Cert1。即证书名称相同但密钥不同。
在这种情况下,JVM尝试使用“Cert1”加载和解密,但无法执行此操作。这就是标头上的字节数不等于正文中的字节数的原因。在这种情况下,我预计会有更多合适的错误,我同意上述错误具有误导性。
希望这可以解决一些困惑!