Table of Contents

OpenAS2 Documentation

This is a conspect of the OpenAS2 documentation “OpenAS2 Server Application”, which can be found here:

1. Introduction

2. Glossary

3. Basic Functional Overview

The OpenAS2 application provides the following mechanisms for sending and receiving files:

All sent and received files are tracked in a database tracking system that updates the progress of the message state in the database at key points in the life cycle of message.

4. Installing OpenAS2

4.1 System Requirements

4.2 Installing Application

4.3 Tuning Java

5. Configuration overview

5.1. Key Configuration Concepts

OpenAS2 server uses four files for configuration:

5.2. Dynamic Configuration Changes

5.3. “home” Configuration Parameter

The folder containing the config.xml file defines the home configuration parameter %home%. All files can be referenced relative to this parameter. This means the default home location for %home% with the current default OpenAS2 folder structure will be [InstallDir]/config

5.4. Passing In Configuration Values

The application supports 2 ways of passing in configuration parameters:

5.4.1. Environment Variables

For instance, the password for the certificates file could be set like this in the config.xml:

<certificates classname="org.openas2.cert.PKCS12CertificateFactory"
filename="%home%/as2_certs.p12”
password="$ENV{AS2_CERTIFICATE_PWD}"
interval="300"/>

Then set the password in the environment as below before running the startup script:

export AS2_CERTIFICATE_PWD=my_secret_password

5.4.2. System Properties

Environment variable replacement occurs BEFORE system properties so you can use environment variables to set properties in the config.xml which in turn are used for other config values. For instance, you can change this in the <properties> section of the config.xml:

<properties storageBaseDir="%home%/../data"

To:

<properties storageBaseDir="$ENV{storageBaseDir}"

6. Application Configuration

6.1. System Level Properties

6.2. Sending Files

6.2.1. Directory Polling Configuration Attributes

6.2.2. Generic Send Directory Poller

6.2.3. Partnerships XML Defined Directory Poller

Minimum required setting in a partnership is to enable a poller:

<pollerConfig enabled="true"/>

The default configuration (set in config.xml) will be overriden by this setting.

If you want to override any of the attributes from the pollerConfigBase element, you simply put the relevant attribute you want to override into the pollerConfig element in the partnership.

6.2.4. Config XML Defined Directory Poller

6.2.5. Restricting Directory Files By Extension Or Name

The directory polling module can be configured to only use files with a specific extension and/or exclude files with a specific extension and/or exclude files based on a regular expresssion match on the entire file name. The following attributes are relevant:

Example:

fileextensionfilter="doc, docx, txt, edi"
fileextensionexcludefilter="tmp"
filenameexcluderegexfilter=".+Tmp[.]{1}.+"

The attributes are evaluated as an AND function so if any of the filters excludes a file it ignores the other filters and excludes the file from processing.

6.2.6. Auto Splitting Large Files

6.3. Receiving Files

To receive and persist files over AS2 from a partner the following should be configured:

My current configuration:

      <module enabled="$properties.module.MessageFileModule.enabled$"
              classname="org.openas2.processor.storage.MessageFileModule"
              filename="$properties.module.MessageFileModule.filename$"
              header="$properties.module.MessageFileModule.header$"
              protocol="as2"
              tempdir="$properties.storageBaseDir$/temp"/>
      <module enabled="$properties.module.AS2ReceiverModule.http.enabled$"
              classname="org.openas2.processor.receiver.AS2ReceiverModule"
              port="$properties.module.AS2ReceiverModule.http.port$"
              errordir="$properties.storageBaseDir$/inbox/error"
              errorformat="sender.as2_id, receiver.as2_id, headers.message-id"/>

6.3.1. Overriding Storage Location Per Partnership

6.3.2. Providing Default File Name

6.4. AS2 Message Tracking

6.5. Overriding Certificate Store Password

6.6. Resend Retry Configuration

6.7. Asynchronous MDN Response Wait Time

6.8. File Name Parsing

6.9. Using A Proxy Server

6.10. Health Check For High Availability Deployment

6.10.1. Healthcheck URI On Existing AS2 Listener

6.10.2. Dedicated Healthcheck Module

6.10.3. HTTP User Agent Header

7. Partner Configuration

config.xml :

   <partnerships classname="org.openas2.partner.XMLPartnershipFactory"
                 filename="$properties.partnership_file$"
                 interval="120"/>

Where $properties.partnership_file$ configured as %home%/partnerships.xml.

So all other stuff is configured in partnerships.xml.

Each partner will require the following entries in the file:

7.1. Partner Definition

7.2. Partnership Definition

The <partnership> element (in partnerships.xml) identifies a specific direction of AS2 message transfer from one partner to another.

The <partnership> child elements that are necessary to properly configure a partnership:

The partnership element attribute values supports using a key value string that can be used to reference other attributes within the same partnership element to ensure consistent configuration. The value field in an attribute can use the format $attribute.XXX$ to reference the value of the attribute name “XXX”.

Example:

<attribute name="some_attrib_name" value="My value: $attribute.other_attrib"/>
<attribute name="other_attrib" value="bingo"/>

7.2.1. Signing

Signing is controlled by the “sign” attribute in the “partnership” element. Remove this element from the partnership to send a message without signing.

Supported signing algorithms are: md2, md5, sha1, sha224, sha256, sha384, sha512

7.2.2. Encryption

Encryption is controlled by the “encrypt” attribute in the “partnership” element. Remove this element from the partnership to send a message without encryption.

Supported algorithms are: 3des, cast5, rc2_cbc, aes128, aes192, aes256

7.2.3. MDN MIC Algorithm

The MDN must be signed using the same algorithm that the sent message was signed with. The recipient partner is told the signature algorithm via a field in the as2_mdn_options attribute and the value uses the $attribute.sign$ dynamic variable to ensure it matches the “sign” attribute as shown in the example below:

<attribute name="as2_mdn_options"
value="signed-receipt-protocol=optional, pkcs7-signature;
signed-receipt-micalg=optional, $attribute.sign$"/>

If you need to send an unsigned MDN then set the attribute on the partnership as below:

<attribute name="as2_mdn_options" value="none"/>

7.2.4. Reject Unsigned Messages

It is possible to reject unsigned messages.
Global configuration (in config.xml):

reject_unsigned_messages="true"

Partnership-specific configuration (through an attribute of partnership tag in partnerships.xml):

<attribute name="reject_unsigned_messages" value="true"/>

7.2.5. Dynamic AS2 Url Configuration

There are 3 ways to set message attributes that can be used in the for dynamic URL’s:

7.3. Example Multi-Partner Configuration

7.4. Configuring the AS2 Message ID

The message ID used for uniquely identifying the message sent can be configured

<properties storageBaseDir="%home%/../data"
  log_date_format="yyyy-MM-dd HH:mm:ss.SSS"
  sql_timestamp_format="yyyy-MM-dd HH:mm:ss.SSS"
  as2_message_id_format="$date.yyyyMMddHHmmssZ$-$rand.123$-$msg.sender.as2_id$_$msg.receiver.as2_id$_$msg.attributes.filename$"
...               
<partnership name="MyCompany-to-PartnerA">
  <sender name="MyCompany"/>
  <receiver name="PartnerA"/>
  <attribute name="protocol" value="as2"/>
  <attribute name="content_transfer_encoding" value="binary"/>
  <attribute name="as2_message_id_format" value="ACME-$date.yyyyMMddHHmmssZ$-
$rand.UUID$"/>

The same can be done with the MDN message ID:

7.5. Content Type

It is possible to override the default value of Content-Type MIME header used in the body MIME part using the content_type attribute.

<attribute name="content_type" value="application/EDIFACT"/>

7.6. Content Transfer Encoding

As of version 1.3.7, the default content transfer encoding uses binary if not explicitly overwritten in the configuration. The default can be changed using the content_transfer_encoding attribute in the partnerships.xml file.

7.7. Supported Encoding Algorithms

The currently supported encoding algorithms are:

7.8. Message Compression

7.9. Custom Mime Headers

Mime headers can be added to the outermost Mime body part for outbound messages and additionally added to the HTPP headers.
…

7.9.1. Static Header Values

…

7.9.2. Dynamic Header Values From File Name

7.9.3. Adding Custom Headers To HTTP

…

7.10. Setting Dynamic Attributes From File Name

Partnership attributes can be added to the partnership definition based on parsing the file name of the document to be sent using a regular expression. Dynamic attributes require 2 partnership attributes:

The extracted name/value pairs can then be referenced in config using the format: $attributes.<attribute name>$

…

7.11. HTTP Authentication

For partners that require HTTP authentication when connecting to their system use the following parameters in the partnership:

For sending files this is in the partnership where the partner is the receiver.

8. AS2 Certificate Configuration

IMPORTANT: This section does NOT cover SSL certificates. SSL certificates are a completely separate set of certificates to the AS2 certificates (for SSL config for HTTPS see the appropriate section in this document)

8.1. Certificate Usage Overview

Two different sets of certificates used in OpenAS2 and they are stored separately:

Import the private and public keys and associated certificate into the OpenAS2 keystore and share the public key with the partner(s).

All trading partners will need to send you their public certificate that must be imported into the AS2 certificate keystore under a unique alias that identifies the particular trading partners public key in your keystore.

Encryption is done using the public key of an X.509 certificate and signing uses a private key. All certificates are stored in a single PKCS12 keystore and identified by their unique alias.

The communication flow for example for communication between “MyCompany” and “PartnerA”:

8.2. Certificate Keystore Configuration

In config.xml:

   <certificates classname="org.openas2.cert.PKCS12CertificateFactory"
                 filename="$properties.as2_keystore$"
                 password="$properties.as2_keystore_password$"
                 interval="300"/>

8.3. Managing Certificate Keystore

Three strategies:

8.4. My Certificates

You can have:

For increased security it is highly recommended you use multiple certificates.

8.4.1. Creating Certificates

Third party tools can be used for this purpose:

This documentation describes only OpenSSL commands. But the same can be done with other tools (e.g. with KeyTool Explorer).

The other option is to use scripts that are included in the installation package. For example this windows DOS shell script:

<INSTALL_DIR>/bin/gen_p12_key_par.bat

Running the script without arguments will show a usage description.

8.4.2. Creating Public Key For Sending To Partner

The public key must be exported from PKCS12 keystore that you created when generating a self signed certificate as described in the previous section. You can export the public key using this command against the keystore:

openssl pkcs12 -clcerts -nokeys -out <output file> -in <keystore file>

8.4.3. Importing Into OpenAS2 Keystore

To import certificates contained in the PKCS12 keystore with the help of OpenAS2 command processor (or remote OpenAS2 app):

cert import <alias> <path+filename> <keystore password>

It is also possible to use third party keystore manager for this task. Then simply replace existing keystore with the new one (which should contain the new certificates).

IMPORTANT: the file should have the extension “.p12”

8.4.4. Supporting Multiple Certificates

The key to supporting multiple certificates for the same partner is ensuring you use a separate as2_id and x509_alias attribute (⇒creating multiple partners).

8.4.5. Overlapping Old And New Certificates When Changing

Use x509_alias_fallback attribute for it:

<partner name="MyCompany256" as2_id="MyCompany2_OID"
x509_alias="MyCompanyCert256" x509_alias_fallback="MyNewCompanyCert256"
email="me@MyCompany.com"/>

…

8.5. Partner Certificates

The certificate(s) that you will obtain from your partner(s) will need to be imported into the keystore you have created for your own certificate. Your partner should send you the public key for their certificate and should be a single file usually with a “.cer” or “.der” extension.

To import partner public keys into the keystore you can either use:

8.5.1. Replacing Existing Public Keys

If your partner certificate has expored or is about to expire and they send you a new certificate, you will need to delete the existing one from the keystore before importing the new one. The OpenAS2 command processor (or remote OpenAS2 app) import command for importing your partners certificate would be in this form:

cert delete <alias>

8.5.2. Importing Public Keys

The OpenAS2 command processor (or remote OpenAS2 app) import command for importing your partners certificate would be in this form:

cert import <alias> <path+filename>

8.5.3. Shell Scripts For Certificate Management

The script uses the Java keytool command and can be found here:

</code>

8.6. Possible Issues With Older Certificates

…

8.7. Suggested Steps For Certificate Setup

8.7.1. My Certificates

… Here is described ho to import the own certificates with the help of shell scripts provided with OpenAS2 installation. I think it is possible to do the it with the help of 3rd party tools (like KeyTool Explorer) …

8.7.2. Partner Certificates

… Here is described ho to import the partner certificates with the help of shell scripts provided with OpenAS2 installation. I think it is possible to do the it with the help of 3rd party tools (like KeyTool Explorer) …

9. Logging System

Loggers are configured in the config.xml file using the “loggers” element.

9.1. Log Output Targets

The logging output can be directed to to multiple destinations including:

9.1.1. Console Logger

The console logger is configured using this entry in the <loggers> element:

<logger classname="org.openas2.logging.ConsoleLogger" />

9.1.2. File Logger

The file logger is configured using this entry in the <loggers> element:

<logger classname="org.openas2.logging.FileLogger" filename="%home%/../logs/log-$date.yyyyMMdd.txt" />

9.1.3. Email Logger

…

9.1.4. Socket Logger

…

9.1.5. Sentry Logger

…

9.2. Log Level Configuration

9.3. Log Date Format Configuration

The default format for the timestamp prefixed to all log entries is the international standard including millisecond precision as of version 2.3.1 (yyyy-MM-dd HH:mm:ss.SSS).
The format can be changed by setting the attribute named log_date_format in the properties element of the config.xml with the desired format.

9.4. Suppressing Invalid HTTP Request Message

…

10. MDN Configuration

MDN's can be sent or received synchronously or asynchronously.

<attribute name="as2_mdn_options" value="signed-receipt-protocol=optional,pkcs7-signature;signed-receiptmicalg=
optional,$attribute.sign$"/>
<attribute name="as2_receipt_option" value="$properties.as2_async_mdn_url$"/>

Per the AS2 specification, an MDN will only be sent on receipt of an AS2 message if the “Disposition-Notification-To” header is present in the received message with a non-empty value.

Although this value is specified to be configured with an email address, it is not utilized for any purpose in the AS2 protocol other than to indicate an MDN is required so can in fact be any random string. To set the “Disposition-Notification-To” header in an outbound message, the as2_mdn_to attribute must be set on the partnership.

The other attribute that must be set is the as2_mdn_options. This defines the encryption algorithm and other MDN settings as specified by the AS2 protocol and the value entered for this attribute will be sent in the “Disposition-Notification-Options” header of the AS2 message.

10.1. Asynchronous MDN Receiver Configuration

In order to specify an asynchronous MDN response from a partner requires setting the following attribute on the partnership element in the partnership configuration:

Receiving an asynchronous MDN requires the “AS2MDNReceiverModule” module. This module declaration requires a port parameter in addition to the class and can be entered as a child member of the processor node in the config file as shown below:

<module classname="org.openas2.processor.receiver.AS2MDNReceiverModule" port=”10081” />

10.2. MDN Sender Configuration

Sending an asynchronous or synchronous MDN requires the “MDNSenderModule” module. Thismodule declaration does not require any parameters other than the class and can be entered as shown below as a child member of the processor node in the config file:

<module classname="org.openas2.processor.sender.MDNSenderModule"/>

11. SSL Certificates - Configuring HTTPS Transport

11.1. SSL Certificates

In order to support inbound HTTP connections over HTTPS to the OpenAS2 application you will need to set up the SSL certificates.

There are 2 possible inbound connections that can be made to OpenAS2:

If you are NOT using ASYNC MDN mode for any outbound transfers and you are NOT receiving any AS2 messages that require using HTTPS ⇒ then you DO NOT need any SSL certificates.

11.2. Inbound Transfers

…

11.3. Outbound Transfers

The partnership definition for the connection URL to your partners AS2 receiver will also have to be set to the appropriate URL with their host name and prefixed with https:

<partnership name="MyCompany-to-PartnerB">
...
  <attribute name="as2_url" value="https://as2.partnerb.com:8443"/>
...

…

If you are not intending to receive MDN responses over HTTP then disable that module by setting it to “false”:

module.AS2MDNReceiverModule.http.enabled="false"
-Dorg.openas2.cert.TrustSelfSignedCN=<Common.Name1>,<Common.Name2>,...

12. Running OpenAS2

12.1. Starting OpenAS2

There are 2 executable script files in the bin folder of the AS2 application root:

The startup script will create the following folders along with sub folders when it starts assuming no change to the default config:

12.2. Command Entry

Just press <ENTER> after start of OpenAS to get a visible prompt. Typing ? will show possible commands.

12.3. Automated Launching As UNIX Daemon

12.3.1. INIT.D Service

12.3.2. SYSTEMD Service

12.4. Windows Service Management

12.4.1. Installing Service

12.4.2. Removing Service

12.4.3. Troubleshooting Windows Service

13. Testing OpenAS2 Transfers

13.1. Single Instance Testing

The default configuration of the OpenAS2 configuration is set up for three partners named:

In the default configuration:

13.2. Multiple Instance Testing

13.3. Using HTTPS Transport

14. Troubleshooting OpenAS2

14.1. Canonicalization For MIC Algorithm 14.2. Binary Encoding 14.3. HTTP Restricted Headers 14.4. CMS Algorithm Protection 14.5. Content Length Versus Chunked 14.6. SSL Certificate Exceptions 14.7. Java Versions Prior To 1.7 14.8. Mime Body Part Logging 14.9. TLSv1.2 14.10. HTTP Read Timeout Errors 14.11. Out Of Memory And File Size Issues 14.12. File System Issues 14.13. Header Folding

15. Partner AS2 Compatibility Settings

16. Remote Control

16.1. Socket Command Processor

16.1.1. Server Side Configuration

16.1.2. Client Side Configuration

16.1.3. Running on deployed server

16.1.4. Running on a separate server

16.1.5. Commands

16.2. REST API Command Processor

16.2.1. Server Side Configuration

16.2.2. Using the REST API

17. Dynamic Variables

18. Appendix: config.xml file structure

19. Appendix: partnership.xml file structure

20. Appendix: command.xml file structure

21. Appendix: Updating database structure

22. Appendix: Creating database DDL for external databases

23. Appendix: Upgrading

24. Appendix: Clustering and Load Balancing

25. Appendix: Maven Artifacts