# Moving from AS2 version 1

Version 27 has a new AS2 engine, version 2, beside the one every earlier version had. This page says why and when to move a partner to it, how version 2 is turned on, and how the server's import tool moves partners over without anything being typed in again.

Both engines run on one server at the same time. Partners are moved one by one, and each can be moved back.

> [!NOTE]
> Version 2 has no pages in the admin pages yet. Everything here is done with settings and admin commands, and is for administrators who are at home with both. Version 1 goes on working and has no end date: there is no need to move a partner that has no problem.

## Why move

| With version 1 | With version 2 |
|---|---|
| the partner's AS2 name holds a password of the server | the partner is known by their signature. No password travels, and none is in receipts or logs. |
| files are held in memory: large files need a large heap, and around 1 GB is the end | files are streamed: size is a matter of disk |
| a signature is checked only if the user has a verification key; an unsigned message is taken | a signature is required unless you decide otherwise for a partner |
| a file is stored as it arrives | a file is stored only after every check has passed |
| a later receipt is posted to whatever address the sender names | only to addresses you allowed |
| a repeated message is stored again | recognised, and answered as before |
| off in [FIPS mode](FIPS-Mode.md) | the engine for FIPS mode |

## What the server tells you

A server that still has version 1 traffic says so, as advice:

| Where | What |
|---|---|
| the log, at start | a line with the count of version 1 partners |
| the log of each AS2 task run on version 1 | "This task uses the legacy AS2 engine (v1). AS2 v2 is available…" |
| alerts | at most one a day, as a plugin message, with counts only. And one when a partner that was moved still arrives at version 1. |
| the status values `as2_v1_status`, `as2_v1_partners`, `as2_v1_ready`, `as2_v1_needs_input`, `as2_v1_kept` | for dashboards and the [variable watcher](Alerts-Variable-Watcher.md). The status is NONE, IN_USE, KEPT_ONLY or MIGRATED. |

It never counts this against the server's health, and it stays quiet for partners you keep on version 1 on purpose.

From the first start of version 27, version 1 also keeps a small journal of the partners it sees: their AS2 names, the address they post to, the certificate they sign with. It holds no passwords. The import tool reads it, so the longer version 27 has run, the more exactly the tool knows your partners.

## Turning version 2 on

Version 2 is off on every server. It is turned on in the server's settings:

| Setting | Is | Unless changed |
|---|---|---|
| `as2v2_enabled` | the engine runs | false |
| `as2v2_paused` | the engine is stopped for a while, without losing anything | false |
| `as2v2_path` | the path it takes messages at | `/as2v2/` |
| `as2v2_store_path`, `as2v2_spool_path` | where it keeps its record of messages, and where files wait while they are checked. Both must be on a local disk of the server, not on a network share. | folders of the server |
| `as2v2_max_message_mb` | the largest message | 20480 |
| `as2v2_unauth_max_mb` | the largest message from a partner without a gate before the body | 100 |
| `as2v2_retention_days`, `as2v2_outbound_retention_days` | how long received and sent messages stay in the record | 30 |
| `as2v2_spool_min_free_mb`, `as2v2_spool_min_free_percent` | free room the quarantine disk must keep; with less, senders are asked to come back later | 2048, 5 |

and on each web port that should take version 2 messages, in the port's entry: `as2v2_allowed`.

The admin command `as2v2_health` answers with the state of the engine, and names the reason when it is not running; `as2v2_getConfig` shows the settings, the stations and the partners. On a test server where the engine was off, `as2v2_health` answered with the state "OFF", empty lists, and the version 1 counts.

Version 2 runs in the internal server only: not in a DMZ server and not in a job engine on another machine.

## The import tool

The tool builds version 2 entries from what version 1 has. Nothing is typed in again.

### 1. Scan and report

```text
as2v2_importLegacy   dry_run=true
```

The tool reads, and changes nothing:

- the journal of version 1 traffic;
- the logs, and the receipts lying in partners' folders;
- every job and every event with an AS2 task;
- every user with AS2 keys, with what they inherit.

Version 1 keeps no list of partners, so the tool finds them from these traces. It answers with a line per partner:

| Verdict | Means |
|---|---|
| converts cleanly | everything needed was found |
| converts with warnings | it will work; read the warnings |
| needs input | something could not be found, usually the certificate a partner signs with, or the password part of their AS2 name |
| stays on version 1 | the partner uses an algorithm that version 2 never sends (RC2, RC4, DES, MD5), or a task is kept on version 1 on purpose |

The report holds no passwords.

What the tool builds:

- **Users that share one decryption key become one station.** The station points at the keystore that is there; no key is copied.
- **Each AS2 name seen from outside becomes a partner** of that station, with the user's verification certificate, a route into the folder that user received in, and the receipt addresses that partner was seen to use.
- **Each AS2 task becomes a partner to send to**, with its address, names and certificate.

### 2. Drafts

```text
as2v2_importApply   action=drafts
```

The entries are saved, switched off. They do nothing yet. Look at them with `as2v2_getConfig`, and correct what the report marked.

### 3. Shadow: try without risk

With `as2v2_shadow_enabled`, every version 1 message of a partner that has a draft is, after version 1 has dealt with it as always, given to version 2 as well, for a check only: decrypt, verify, compare. Version 2 stores nothing and sends nothing.

```text
as2v2_shadowReport
```

answers per partner: so many of so many identical, or the first difference, such as a message without a signature where the draft demands one. When a partner shows only identical results for its usual traffic, it is ready.

A difference in trust blocks: if version 1 refused a signature that version 2 would have accepted, the partner is not ready, whatever the counts say.

### 4. Switch a partner

```text
as2v2_importApply   action=switch
```

for one partner. From then on version 2 takes that partner's messages **at the address and under the AS2 name the partner already uses**. The partner changes nothing.

Where the partner's AS2 name carries a password, the tool may use the password once, after checking that it still signs in, to make a stored hash for version 2. The password itself is not kept. The partner keeps sending the same name; version 2 checks it against the hash and then goes on by the signature. Such a stand-in ends by itself after a time: move the partner to a plain AS2 name, and change the user's password, at leisure.

And for sending:

```text
as2v2_importApply   action=task_switch
```

sets the partner's AS2 tasks to the new engine. The job as it was is kept as a backup beside it.

A partner on a port without TLS is switched only if every message seen from them was encrypted; version 2 then demands encryption from them.

### 5. Back

```text
as2v2_importApply   action=rollback
as2v2_importApply   action=task_rollback
```

put a partner, or its tasks, back on version 1. Nothing of version 1 was changed by the switch, so this is immediate.

## What is different after the move

Tell the people who work with the files:

| Version 1 did | Version 2 |
|---|---|
| stored a copy of each receipt beside the file, as `.out.mdn` | keeps receipts in its own record |
| could add an id to each file name (**Unique AS2 filenames**) | names a file that exists by its route's rule: a new unique name unless set otherwise |
| took AS2 names in any case | AS2 names are exact: upper and lower case count |
| let any user receive | refuses some users as the one files are written as: administrators, users without HTTPS, users whose password is ending |

## Things to know

- **Switch a partner's receiving and sending together** when their AS2 names are tied: a later receipt for a version 1 send that arrives at version 2 is not handed to the waiting task.
- **Keep the keystores where they are.** Version 2 reads the same files.
- **One server.** Version 2 keeps its record on a local disk, with one writer. In a cluster it runs on one node.
- **Up to 100 stations and 500 partners.**
- **The log kind `AS2V2`** must be added to what is logged to see the engine's lines: [What is logged](Prefs-Logging-Events.md).

## Not tried for this page

No partner was imported or switched for this page. The commands and what they do are taken from the design and build record of the import tool. That record says what was tested when it was built: the scan, the mapping, the shadow comparison and the switch were run in test harnesses and on real version 1 messages; the parts that need a running server, the password check for a stand-in, the admin commands from end to end, and the alerts, had not been run. Try the dry run and the shadow on your own server before you switch anything.
