This is a comprehensive Go library implementing the eDelivery AS4 2.0 specification for secure, reliable business-to-business (B2B) messaging. The library provides a complete implementation of the AS4 protocol as specified by the European Commission's eDelivery program.
The library implements:
- eDelivery AS4 2.0 - Main specification
- OASIS AS4 Profile of ebMS 3.0 Version 1.0 - Core AS4 standard
- OASIS ebXML Messaging Services Version 3.0 Part 1 - ebMS3 core
- WS-Security 1.1.1 - Message-level security
- SOAP 1.2 - Envelope format
go-as4/
├── pkg/
│ ├── as4/ # Main client/server API
│ ├── message/ # AS4 message structures (SOAP/ebMS3)
│ ├── security/ # WS-Security with Ed25519/X25519
│ ├── transport/ # HTTPS with TLS 1.2/1.3
│ ├── reliability/ # Reception awareness, retry, duplicate detection
│ ├── compression/ # GZIP payload compression
│ ├── pmode/ # Processing Mode configuration
│ └── mep/ # Message Exchange Patterns
├── examples/ # Usage examples
└── internal/ # Internal utilities
- SOAP 1.2 Envelope: Full implementation with proper namespaces
- ebMS3 Headers:
- MessageInfo (ID, timestamp, correlation)
- PartyInfo (sender/receiver identification)
- CollaborationInfo (service, action, conversation)
- MessageProperties (custom metadata)
- PayloadInfo (payload references)
- Signal Messages: Receipts and errors
- Builder Pattern: Easy message construction
- Minimum: TLS 1.2
- Recommended: TLS 1.3
- Cipher Suites:
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
-
Digital Signature:
- Algorithm: Ed25519 (Edwards-curve Digital Signature Algorithm)
- Digest: SHA-256
- URI:
http://www.w3.org/2021/04/xmldsig-more#eddsa-ed25519
-
Encryption:
- Key Agreement: X25519 (Curve25519 Diffie-Hellman)
- Key Derivation: HKDF with HMAC-SHA256
- Data Encryption: AES-128-GCM
- Key Wrap: AES-128 Key Wrap
- URIs:
- X25519:
http://www.w3.org/2021/04/xmldsig-more#x25519 - HKDF:
http://www.w3.org/2021/04/xmldsig-more#hkdf - AES-GCM:
http://www.w3.org/2009/xmlenc11#aes128-gcm
- X25519:
-
Reception Awareness:
- Message tracking with state management
- Synchronous receipts
- Missing receipt detection (EBMS:0301)
-
Retry Mechanism:
- Configurable max retries
- Exponential backoff
- Per-message retry tracking
-
Duplicate Detection:
- SHA-256 message hashing
- Configurable time window (default: 24 hours)
- Automatic cleanup of expired entries
-
Error Handling:
- Standard AS4 error codes (EBMS:0202, EBMS:0301, EBMS:0303)
- Structured error reporting
- GZIP Compression: Standard GZIP (RFC 1952)
- Smart Compression: Skips already-compressed formats
- Part Properties: Proper metadata for MimeType and CharacterSet
- Configurable: Can be enabled/disabled per P-Mode
-
HTTPS Client:
- Configurable TLS versions and cipher suites
- Connection pooling
- Timeout management
-
HTTPS Server:
- TLS server with client authentication support
- Graceful shutdown
- Request routing
Complete P-Mode parameter support:
- Agreement reference
- MEP and MEP binding
- Protocol parameters (endpoint URL, SOAP version)
- Business info (service, action, MPC)
- Security configuration (signing, encryption, receipts)
- Reception awareness settings
- Payload service (compression)
- Error handling configuration
-
One-Way/Push (Required):
- Single message with synchronous receipt
- Standard for most B2B exchanges
-
Two-Way/Push-and-Push (Required):
- Request-response correlation
- Separate push for response
- RefToMessageId linking
-
Pull (Optional enhancement):
- Framework provided for future implementation
✅ Message Structure:
- Empty SOAP Body (payloads in MIME attachments)
- Mandatory eb:Service and eb:Action
- Party ID with type attribute required
- ConversationId for correlation
- MessageId in RFC2822 format
✅ Security:
- Transport layer: TLS 1.2 minimum (SSL 3.0, TLS 1.0/1.1 prohibited)
- Message layer: Mandatory signing and encryption
- Ed25519 signatures with SHA-256
- X25519/HKDF/AES-128-GCM encryption
- Non-repudiation of origin and receipt
✅ Reliability:
- Synchronous receipts only
- Reception awareness enabled
- Retry with exponential backoff
- Duplicate detection with 24-hour window
✅ Compression:
- GZIP recommended for all suitable payloads
- Metadata in PartProperties
- Applied before signing/encryption
✅ Error Handling:
- Synchronous error responses only
- Standard error codes
- Delivery failure reporting
✅ Implemented constants for:
- Service:
http://docs.oasis-open.org/ebxml-msg/ebms/v3.0/ns/core/200704/service - Action:
http://docs.oasis-open.org/ebxml-msg/ebms/v3.0/ns/core/200704/test
✅ Go's standard library provides automatic IPv4/IPv6 dual-stack support
// Create AS4 client
config := &as4.ClientConfig{
HTTPSConfig: transport.DefaultHTTPSConfig(),
SecurityConfig: security.NewSecurityConfig(
security.WithSigningKey(signingKey),
security.WithEncryptionCert(recipientCert),
),
PMode: pmode.DefaultPMode(),
}
client, _ := as4.NewClient(config)
// Build message
msg := message.NewUserMessage(
message.WithFrom("sender-id", "urn:oasis:names:tc:ebcore:partyid-type:unregistered"),
message.WithTo("receiver-id", "urn:oasis:names:tc:ebcore:partyid-type:unregistered"),
message.WithService("http://example.com/service"),
message.WithAction("submitOrder"),
)
msg.AddPayload(orderData, "application/xml")
envelope, payloads, _ := msg.BuildEnvelope()
// Send message
receipt, err := client.SendMessage(ctx, envelope.Header.Messaging.UserMessage,
payloads, "https://receiver.example.com/as4")The architecture supports optional profile enhancements:
- Four Corner Topology: Framework for intermediary routing
- Dynamic Sender/Receiver: Discovery-based configuration
- Pull Feature: Message polling (partial implementation)
- Large Message Split/Join: For messages > 2GB
- ebCore Agreement Update: Certificate updates
Comprehensive test suite included:
- Message builder tests
- Compression/decompression
- Message tracking and reliability
- P-Mode configuration
- Security algorithm constants
- MEP constants validation
Run tests: make test
The implementation uses state-of-the-art elliptic curve cryptography:
-
Ed25519 Signatures:
- Fast, secure, and compact
- 128-bit security level
- Resistant to timing attacks
-
X25519 Key Agreement:
- Curve25519 Diffie-Hellman
- Forward secrecy
- Safe against side-channel attacks
-
HKDF Key Derivation:
- Standards-compliant (RFC 5869)
- Unique keys per message
- Random salt and info parameters
- NIST 800-52r2: TLS configuration
- BSI TR-02102-2: German security standards
- ECRYPT CSA: European cryptographic recommendations
- RFC 9325: TLS/DTLS recommendations
✅ Complete message structure ✅ Security framework (Ed25519/X25519) ✅ Transport layer (HTTPS/TLS) ✅ Reliability (tracking, retry, duplicate detection) ✅ Compression (GZIP) ✅ P-Mode configuration ✅ MEP support ✅ Client/Server API ✅ Examples and documentation
🔧 MIME Multipart Handling:
- Currently payloads are tracked but not serialized to MIME
- Need multipart/related envelope creation
- Content-ID reference handling
🔧 Complete Encryption:
- AES-GCM encryption implementation
- Key wrapping implementation
- MIME part encryption
🔧 XML Signature:
- Canonicalization (C14N)
- Reference digest computation
- Signature generation and verification
🔧 Receipt Validation:
- Non-repudiation receipt structure
- Signature verification on receipts
🔧 Pull MEP:
- Pull signal generation
- MPC (Message Partition Channel) support
- Pull response handling
- Connection Pooling: HTTP transport uses connection pooling
- Compression: Reduces bandwidth for large payloads
- Efficient Hashing: SHA-256 for duplicate detection
- Concurrent Safe: Message tracker uses proper locking
- eDelivery AS4 2.0
- OASIS AS4 v1.0
- OASIS ebMS3 Core
- RFC 8032 - Edwards-Curve Digital Signature Algorithm
- RFC 7748 - Elliptic Curves for Security
- RFC 5869 - HKDF
MIT License - See LICENSE file
See CONTRIBUTING.md for guidelines
- ✅ Core message structure
- ✅ Security framework
- ✅ Basic transport
- ✅ Reliability features
- ✅ Compression
- ✅ P-Mode configuration
- 🔧 Complete MIME handling
- 🔧 Full encryption implementation
- 🔧 XML Signature implementation
- 🔧 Receipt validation
- Pull MEP support
- Four Corner Topology
- Dynamic discovery
- Large message split/join
- ebCore Agreement Update
For issues, questions, or contributions, please use the GitHub repository.