IOException reading content when I am sending a stream
opened this issue · comments
Hi,
I try to read and send a text file to the as2 server and I get an OException exception .
I set the parameters as below :
request.contentType = "application/octet-stream";
request.stream = new FileInputStream("file.txt");
The error log is below :
[2014-09-03 17:41:42,844] [ERROR] [Thread-8] Error decrypting [<Test-03092014174127+0300-6265@OpenAS2A_OpenAS2B>]: IOException reading content. -- com.helger.as2lib.processor.receiver.net.AS2ReceiverHandler.decryptAndVerify(AS2ReceiverHandler.java:277)
In fact I catch the exception when the "SMIMEEnveloped" parsing in the function "decrypt" in the class "BCCryptoHelper" :
final SMIMEEnveloped aEnvelope = new SMIMEEnveloped (aPart);
Then how I can to send a file to the server?
Thank you
Can you please post the whole sender settings - thanks
Yes the sender settings are below :
settings.p12FilePath = new ClassPathResource ("config/keys/as2key.pfk").getAsFile ().getAbsolutePath ();
settings.p12FilePassword = "123123";
settings.senderAs2Id = "OpenAS2A";
settings.senderEmail = "tulay.kaya@mebitech.com";
settings.senderKeyAlias = "test";
settings.receiverAs2Id = "OpenAS2B";
settings.receiverKeyAlias = "test";
settings.receiverAs2Url = "http://localhost:10080/HttpReceiver";
settings.partnershipName = "test";
settings.mdnOptions = "signed-receipt-protocol=optional, pkcs12-signature; signed-receipt-micalg=optional, sha1";
settings.encrypt = false ? null : "3des";
settings.sign = false ? null : "sha1";
final Request request = new Request ();
request.subject = "tulaysubject";
request.contentType = "application/octet-stream";
try {
request.stream = new FileInputStream("file.txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
I can reproduce the problem, as soon as a filename or an InputStream is used. Working on it...
Fixed. The problem was in the Test client itself. Edit EdiIntAs2Client._buildMessage and replace the message building with the following code:
final MimeBodyPart part = new MimeBodyPart ();
if (aRequest.stream != null)
{
part.setContent (StreamUtils.getAllBytes (aRequest.stream), aRequest.contentType);
}
else
if (aRequest.filename != null)
{
part.setContent (StreamUtils.getAllBytes (new FileInputStream (aRequest.filename)), aRequest.contentType);
}
else
{
part.setText (aRequest.text);
}
aMsg.setData (part);
Hi! It works! Thank you.
Tulay