Appearance
WS-Security and signature wrapping Since v0.2
Partners that call a SOAP service often sign their messages. The product checks those signatures itself, so the application only sees messages a trusted partner signed, recently, once, and with the signed parts exactly where the application reads them. It can also decrypt encrypted messages for an application that does not handle WS-Security, and sign or encrypt the answers.
Before you begin
- Role:
operatorfor the application. Storing private keys needsadmin. - The partners' certificates, or the CA that issued them, as PEM files.
- For decryption or signed answers, the private key as a PEM file.
Turn on signature checks
text
1. Open Applications > All applications > the application > Request checks > API protection.
2. Open the WS-Security tab.
3. In the Certificates card, add each trusted certificate (role trusted).
4. In the settings form, enter SOAP paths, for example /soap/*.
5. Select Preview changes, add a comment and select Apply.sh
waap api wssec cert set -app shop -name partner-ca.pem -role trusted -f partner-ca.pem -m "partner CA"
waap api set -app shop -m "WS-Security" ws_security.paths=/soap/*yaml
# applications[].policy.api.ws_security
ws_security:
paths: [/soap/*]
trusted_certs: [partner-ca.pem]The module follows the application's mode. Requests on other paths are not touched, and requests without a body (GET ?wsdl) pass. With Required empty, nothing is required, but signatures that are present are still checked and the wrapping checks still run.
Decrypt messages for the application
Store the private key partners encrypt for, then turn decryption on.
text
1. On the WS-Security tab, in the Keys card, select Store key. Enter a name, the kind
decrypt and the PEM key.
2. Set Decrypt for the upstream, and Decrypt key to that name.
3. Select Preview changes, then Apply.sh
waap api wssec key set -app shop -name partner-dec -kind decrypt -f key.pem
waap api set -app shop -m "decrypt" ws_security.decrypt=true ws_security.decrypt_key=partner-decyaml
# applications[].policy.api.ws_security
decrypt: true
decrypt_key: partner-decPrivate keys are write-only. They sit in the key store, replicated to the standby and synced to inspection, never in the configuration, versions, audit records or events. The list shows the name, kind, a fingerprint of the public key, when and by whom. Storing a key under an existing name and kind replaces it. A key that the running configuration uses cannot be removed.
Decryption also happens in detect mode
Decrypting is part of how the application works, so it happens in detect too, and the trace shows it as a change. A key missing on a node is an inspection error, and the failure policy decides (fail-open passes the encrypted message on).
Sign or encrypt answers
text
1. Store a key of kind sign in the Keys card, and add the key's certificate in the
Certificates card with the role signing.
2. Set Sign answers, Signing key and Signing certificate. Optionally set Encrypt answers.
3. Select Preview changes, then Apply.sh
waap api wssec key set -app shop -name resp-sign -kind sign -f sign.pem
waap api wssec cert set -app shop -name resp.pem -role signing -f resp.pem -m "signing cert"
waap api set -app shop -m "sign answers" ws_security.sign_responses=true ws_security.sign_key=resp-signyaml
# applications[].policy.api.ws_security
sign_responses: true
sign_key: resp-sign
sign_cert: resp.pem
encrypt_responses: falseSigned answers get a 5-minute Timestamp, the certificate and a signature over Body and Timestamp. Encrypted answers use AES-256-GCM with RSA-OAEP for the certificate that signed the request; only RSA certificates can receive them, and Required must contain signature. Answers must fit the response body limit (policy.response.max_body). Answers that are not SOAP pass unchanged. To hide sensitive data and error text in answers, see Data leaks and response signatures.
What is checked, in order
- A document with a document type declaration or entity, a malformed one, one with a repeated attribute, or one over the XML limits is refused before any key is touched.
- Wrapping checks: unique Ids, one Header, one Body and one Security header, no Body anywhere else, each signed element where the application reads it, nothing unsigned next to a signed operation element, references inside the message, only exclusive canonicalization and enveloped signature transforms, and no key fetched from elsewhere.
- Timestamp: not created later than now plus the clock skew, not older than Oldest message accepted (plus skew), not expired.
- Signature: an accepted algorithm (SHA-1 and DSA never), RSA keys of at least 2048 bits, a signer certificate that is trusted or chains to a trusted one (no revocation lookups), a signature that verifies, and digests that match.
- The parts in Parts that must be signed are covered by a verified signature.
- Replay: a signature seen within Replay window is refused. Each node keeps its own record, up to 100,000 signatures per application.
Settings reference
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
WS-Security mode (ws_security.mode) | Whether failures refuse or only log. | empty (same as API protection) | detect, block, empty | detect wins over the application's block |
SOAP paths (ws_security.paths) | Paths where signed SOAP messages arrive. | none (checks off) | path list | all |
Required (ws_security.require) | What every message must carry. | signature, timestamp | signature, timestamp; empty list: nothing | all |
Parts that must be signed (ws_security.signed_parts) | Parts a verified signature must cover. | body, timestamp | body, timestamp, header:Local or header:Local:namespace; up to 8 | a signature is required |
Trusted certificates (ws_security.trusted_certs) | PEM files of CAs or of the signers. | none | up to 32 files; at least one when a signature is required | all |
Signature algorithms (ws_security.algorithms) | Accepted signature methods. | rsa-sha256, rsa-sha512, ecdsa-sha256, ecdsa-sha384 | the product's method names | all |
Clock skew allowed (ws_security.max_clock_skew) | How far the sender's clock may differ. | 5m | 0s to 1h | all |
Oldest message accepted (ws_security.max_age) | Age after which a message is refused, whatever its expiry. | 5m | 1s to 24h | all |
Replay window (ws_security.replay_window) | How long signatures are remembered. | 10m | 1s to 24h; at least the oldest message accepted | all |
Decrypt for the upstream (ws_security.decrypt) | Decrypts XML Encryption parts. | false | true, false | both modes |
Decrypt key (ws_security.decrypt_key) | Key store name of the decryption key. | none | key name | decrypt on |
Sign answers (ws_security.sign_responses) | Signs SOAP answers. | false | true, false | all |
Signing key (ws_security.sign_key) | Key store name of the signing key. | none | key name | sign answers on |
Signing certificate (ws_security.sign_cert) | PEM file of the signing key's certificate. | none | file name | sign answers on |
Encrypt answers (ws_security.encrypt_responses) | Encrypts the answer Body. | false | true, false | needs signature in Required |
Wrapping checks (ws_security.wrapping) | Signature wrapping checks. | true | true, false | all |
Rules
api.wssec.missing, .signature, .unsigned_part, .algorithm, .cert, .timestamp, .replay, .decrypt, .document and .limit, and the wrapping rules api.xsw.duplicate_id, .reference, .moved, .duplicate_body and .unsigned_sibling. Each names the element path or Id and the value that failed. Exceptions accept the prefixes api.wssec. and api.xsw..
Limits
| Limit | Value |
|---|---|
| Signatures per message | 4 |
| References per signature | 16 |
| Transforms per reference | 4 |
| Encrypted parts | 8 |
| Certificate size | 64 KiB |
| Certificates per KeyInfo | 8 |
| Certificate chain | 5 |
| Decrypted content | at most the request body limit, checked against the XML limits again |
| Replay record | 100,000 signatures per application and node |
Troubleshooting
Every signed message is refused with api.wssec.cert
- Cause: the signer's certificate does not chain to a trusted certificate.
- Check: the event shows subject, issuer and the reason.
- Fix: add the partner's CA or certificate under Trusted certificates.
A message is refused with api.wssec.timestamp
- Cause: the sender's clock is off, or the message is older than Oldest message accepted.
- Check: the event shows the created and expires values.
- Fix: correct the clock, or raise Clock skew allowed.
The overview warns api.key_missing
- Cause: the policy names a key that is not stored on this node.
- Fix: store it with
waap api wssec key set. The policy still applies meanwhile.