EldoS | Feel safer!

Software components for data protection, secure storage and transfer

AS2 over HTTPS Example

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
Posted: 03/10/2013 23:14:23
by Ian Blakeley (Basic support level)
Joined: 03/10/2013
Posts: 2

Is there a Delphi example of how to send an AS2 message over HTTPS ie like the provided AS2Sender and AS2Receiver sample applications but using HTTPS

For example
Server (Receiver):

Server := TIdHttpServer.Create(nil);
SSLIOHandler:= TIdServerIOHandlerSSLOpenSSL.Create(Server);
Server.IOHandler:= SSLIOHandler;
SSLIOHandler.SSLOptions.CertFile:= 'xxx.cer';
SSLIOHandler.SSLOptions.KeyFile:= 'xxx.key';
Server.OnComandGet := ServerCommandGet; // as per AS2Receiver example

Client (Sender)
Basic Indy client would be something like:
client := TIdHttp.Create(nil);
SSLHandler:= TIdSSLIOHandlerSocketOpenSSL.Create(client);
client.IOHandler:= SSLHandler;
client.Request.BasicAuthentication:= true;

But using TElAS2Client ??

Posted: 03/11/2013 01:12:19
by Eugene Mayevski (Team)

Regarding Sender: TElAS2Client internally uses TElHTTPSClient which IS an HTTPS client component. You control SSL-related properties of TElAS2Client using TElAS2Client.SSL property.

Regarding receiver: TIdHTTPServer is extended with SecureBlackbox' IOHandler as shown in the sample in <Samples>\Delphi\SSLBlackbox\Server\Indy\IOHandler10 folder.

Sincerely yours
Eugene Mayevski
Posted: 03/11/2013 01:42:42
by Ian Blakeley (Basic support level)
Joined: 03/10/2013
Posts: 2

I tried to compile IOHandlerDemo but got:

File not found 'SBIndyServerIOHandler10.dcu'
Posted: 03/11/2013 01:48:48
by Eugene Mayevski (Team)

There's a readme file in the folder. Please do us a favor and read it.

Sincerely yours
Eugene Mayevski
Posted: 03/15/2013 06:34:24
by John Anderson (Priority Standard support level)
Joined: 03/15/2013
Posts: 24

Is there an example of how to use AS2 with SSL in C# rather than in Delphi? I can't see an equivalent to "Samples\Delphi\SSLBlackbox\Server\Indy\IOHandler10 folder" and for some reason the SSLSocketDemo seems to use older versions of the library components that I don't have in my evaluation copy...
I already found the previous answer about adding SSL to
Samples\C#\EDIBlackbox\AS2\Sender using a line of code like
as2Client.SSL.ClientCertStorage = myCertStorage;
But, how do I do it for the Receiver?
I need to prove the concept so I can approve purchase of the SecureBlackBox suite...
Posted: 03/15/2013 06:56:14
by Alexander Ionov (Team)

The Receiver demo in C# is based on the standard HttpListener class provided by .NET Framework. So please read HttpListener's documentation in order to get an idea how to make HttpListener to support SSL.

BTW, usualy receiving part of AS2 infrastructure is created based on a full featured web server like Apache, IIS, etc. This could be an asp.net solution for IIS, or a mod for Apache, etc. So please consider that both Receiver samples are created in order ONLY to show how to handle incoming AS2-messages on the server side and how to create corresponding AS2-receipts. They are highly not recomended to be used as standalone solutions.

Best regards,
Alexander Ionov
Posted: 03/15/2013 07:15:38
by John Anderson (Priority Standard support level)
Joined: 03/15/2013
Posts: 24

Thanks for the speedy response.

Actually I am required to create a two way AS2 connector that can
a) send an AS2Message (and if configured receive a receipt (MDN) synchronously)
b) receive an asynchronous MDN
c) receive an AS2Message (and if configured send a receipt (MDN) synchronously)
d) send an asynchronous MDN

Thus I suppose I need to create Sender and Receiver threads and some common data structures.

Do you think the code of the two examples will give me sufficient help to prove the concept?
Posted: 03/15/2013 07:39:48
by Alexander Ionov (Team)

With SecureBlackbox you can (by tasks):
- use TElAS2Message class in order to prepare outgoing AS2 messages
- use TElAS2Client class in order to send the prepared message to your partners and to receive synchronous receipts
- use TElAS2Receipt class in order to parse the received receipts

b) use TElAS2Receipt class in order to parse the received receipts

- use TElAS2Message class in order to parse incoming AS2 messages
- use TElAS2Receipt class in order to prepare outgoing receipts

d) use TElAS2Client class in order to send the prepared receipts asynchronously

We have TElHTTPSServer component which can be used to handle incoming http requests and our TElSocket class can accept incoming connections. But by now, we do not provide a complete solution for handling incoming as2 messages from the box.

Best regards,
Alexander Ionov
Posted: 03/19/2013 09:50:49
by John Anderson (Priority Standard support level)
Joined: 03/15/2013
Posts: 24

Can you explain what effect the Silent argument on ElHTTPSServer.Close(bool silent) has on the exceptions thrown? The name implies that if set true the Close just happens without any protest... is that the case? In your sample code it is always set to false, do you do that for any particular reason?

I am struggling to understand how to design the threading necessary to use this server component because the 1.5 second delay on the Close seems to prevent the thread exiting correctly if another request comes along before the Close and the Dispose have completed and the TcpClient has been Closed.

The snippet of code thats causing me the problem looks like this:-

public void Dispose()
   if (!c_disposed)
      m_httpsServ.Close(true); //was m_httpsServ.Close(false);


      c_disposed = true;

Posted: 03/19/2013 09:58:46
by Vsevolod Ievgiienko (Team)


You can read about Silent parameter here: http://www.eldos.com/documentation/sb...close.html

The 1.5 second delay can be temporary removed by requesting an unlock key: https://www.eldos.com/sbb/trial-limitations.php
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.



Topic viewed 5335 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!