Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Go tooling writes module files with LF on every platform.
go.mod text eol=lf
go.sum text eol=lf

# Preserve the checksum-pinned Unicode corpus byte for byte.
/tests/testdata/unicode/NormalizationTest-17.0.0.txt -text
20 changes: 18 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: check

on:
push:
branches: [master]
pull_request:
merge_group:
workflow_dispatch:
Expand Down Expand Up @@ -76,11 +77,26 @@ jobs:
run: make examples
interop:
runs-on: ubuntu-26.04
timeout-minutes: 45
timeout-minutes: 90
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run full interoperability checks in Docker
- name: Restore pinned interop inputs
id: interop-inputs
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: /tmp/xmlsec-interop-inputs
key: ${{ runner.os }}-interop-inputs-v1-${{ hashFiles('build/interop-inputs.txt') }}
restore-keys: ${{ runner.os }}-interop-inputs-v1-
- name: Prepare and verify pinned interop inputs
run: sh build/prepare-interop.sh /tmp/xmlsec-interop-inputs
- name: Save verified interop inputs
if: steps.interop-inputs.outputs.cache-hit != 'true'
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: /tmp/xmlsec-interop-inputs
key: ${{ steps.interop-inputs.outputs.cache-primary-key }}
- name: Run required external checks and Shibboleth/OpenAM/GSA SOAP servers
run: make interop-docker
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ verification, and supported SAML WebSSO flows. Builds without CGO.

- **Sign and verify XML documents** with XMLDSig, including enveloped, enveloping
and detached signatures.
- **Encrypt and decrypt XML or bytes** with AES-GCM, using direct keys, RSA-OAEP
or AES Key Wrap.
- **Encrypt and decrypt XML or bytes** with AES-GCM, using direct keys, RSA-OAEP,
AES Key Wrap or ECDH-ES/ConcatKDF.
- **Select, transform and canonicalize XML** with XPath, XSLT and canonicalization
APIs for documents, subtrees and node sets.
- **Work with keys, certificates and signature evidence** using PEM/DER,
protected PKCS#8/PKCS#12 containers, offline PKIX validation, CMS, timestamps
and supported XAdES profiles.
- **Build solicited SAML WebSSO flows** for service providers and identity
providers, with signed metadata, POST/Redirect bindings and state/replay stores.
providers, with signed metadata, POST/Redirect/Artifact bindings, bearer and
holder-of-key ECP, and state/replay stores. Separate APIs handle logout,
identifier management, authority queries and assertion retrieval.

The optional [CLI](docs/cli.md) exposes operations through the same public APIs.

Expand Down Expand Up @@ -138,15 +140,19 @@ The API is **experimental**. The library implements specific profiles of the
listed standards; full standards conformance and an independent security audit
have not been established.

The document security parser rejects DTDs and external entities. XPath/XSLT
language input has a separate bounded, nonvalidating DTD mode with explicit
external resource policy; see
The document security parser rejects DTDs and external entities. Explicit
`document.ParseOptions{NonValidating: true}` and XPath/XSLT language input provide
bounded, nonvalidating DTD processing with explicit external resource policy; see
[XML input profiles](docs/transforms.md#xml-input-profiles). XSD validation is
unsupported. The XPath/XSLT engine implements selected XPath 1.0/2.0/3.0/3.1
and XSLT 1.0/2.0/3.0 features. Complete Basic XSLT conformance remains open;
[validation profiles](docs/language-baseline.md) define the required suite checks.
Schema awareness and W3C streamable execution are unsupported. SAML support covers
solicited WebSSO; it does not include SLO, Artifact/ECP or encrypted assertions.
solicited WebSSO, including encrypted assertions, identifiers and attributes,
SLO, Artifact/SOAP, bearer and X.509 holder-of-key ECP/PAOS, and NameID management.
See [SAML integration](docs/saml.md) for supported editions and state contracts,
and [authority integration](docs/saml-authority.md) for queries, assertion retrieval
and NameID Mapping.

See [compatibility](docs/compatibility.md) for supported profiles, exclusions and
known interoperability differences, and [standards](docs/standards.md) for primary
Expand All @@ -162,7 +168,9 @@ its consistency checks do not establish full standards conformance.
[key formats](examples/keys) and [certificate and evidence verification](examples/trust).
- **XML processing:** [XPath/XSLT guide](docs/transforms.md),
[transform examples](examples/transforms) and [streaming and memory](docs/streaming.md).
- **SAML:** [WebSSO example](examples/sso) and [Redirect binding](examples/redirect).
- **SAML:** [integration guide](docs/saml.md),
[authority queries and mapping](docs/saml-authority.md),
[WebSSO example](examples/sso) and [Redirect binding](examples/redirect).
- **Reference:** [API guide](docs/usage.md), [all examples](examples),
[CLI](docs/cli.md), [package architecture](docs/architecture.md) and
[security policy](SECURITY.md).
Expand Down
10 changes: 6 additions & 4 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ GOLANGCI_LINT ?= golangci-lint
GOLANGCI_LINT_CONFIG ?= build/.golangci.yml
DOCKER ?= docker
INTEROP_DOCKER_IMAGE ?= xmlsec-interop:local
INTEROP_INPUT_CACHE ?= /tmp/xmlsec-interop-inputs
FUZZ_ARGS ?=
BENCH_ARGS ?=
INTEROP_ARGS ?=
Expand Down Expand Up @@ -53,8 +54,7 @@ suites:

# Optional independent engines; never part of ordinary Go checks.
interop:
$(GO) test -tags=interop -count=1 -v -timeout=20m ./transform -run=Compare
$(GO) test -tags=interop -count=1 -v -timeout=15m ./tests/interop -args $(INTEROP_ARGS)
GO="$(GO)" bash build/interop.sh $(INTEROP_ARGS)

# The same complete Linux run used by the Docker image.
interop-full:
Expand All @@ -64,8 +64,10 @@ interop-full:
java -version
pkg-config --modversion xmlsec1-openssl libxml-2.0
$(GO) test -race -count=1 ./...
$(MAKE) interop INTEROP_ARGS="-suite=all"
XMLSEC_P7_EXPORT_FIXTURES=/tmp/xmlsec-interop-history $(GO) test -count=1 ./xades -run '^TestHistoricalExpiredTSAArchiveEvidence$$'
XMLSEC_DSS_FIXTURE_DIR=/tmp/xmlsec-interop-history XMLSEC_DSS_CA_PEM=root.pem sh build/dss.sh --inside-all

interop-docker:
$(DOCKER) build --file build/interop.Dockerfile --tag "$(INTEROP_DOCKER_IMAGE)" .
sh build/prepare-interop.sh "$(INTEROP_INPUT_CACHE)"
$(DOCKER) build --build-context "interop-downloads=$(INTEROP_INPUT_CACHE)" --file build/interop.Dockerfile --tag "$(INTEROP_DOCKER_IMAGE)" .
$(DOCKER) run --rm --network=none "$(INTEROP_DOCKER_IMAGE)"
20 changes: 19 additions & 1 deletion build/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
# Build support

Run make from the module root; its Makefile includes [Makefile](Makefile).
The interoperability targets require Bash as well as a POSIX shell.
[.golangci.yml](.golangci.yml) configures lint/formatting and
[interop.Dockerfile](interop.Dockerfile) supplies optional native test engines.
The Docker build context is the module root.
The Docker build context is the module root. `make interop-docker` first prepares
the checksum-pinned downloads listed in [interop-inputs.txt](interop-inputs.txt)
and passes their cache as the `interop-downloads` named build context. Override
`INTEROP_INPUT_CACHE` to reuse another cache directory. Tests run offline.

[interop.sh](interop.sh) runs both external suites. In the CI image,
`XMLSEC_REQUIRE_INTEROP=1` rejects skipped, failed or incomplete test streams.
The full recipe starts the official DSS service and the test-owned Shibboleth
IdP/Jetty, OpenAM/Tomcat and Google GSA deployments; no external service
credentials are required.

See [testing](../docs/testing.md) for commands and prerequisites.

The `authority-http` selection covers AuthnQuery, AssertionIDRequest and NameID
Mapping using OpenAM 16.1.4, plus AuthzDecisionQuery using Google GSA adaptor
4.1.4. The OpenAM test WAR has one disclosed serializer correction in
[openam-nameid-order.patch](openam-nameid-order.patch), compiled offline by
[patch-openam.sh](patch-openam.sh); GSA uses its unmodified upstream example and
handler. See [the coverage boundaries](../docs/saml-authority.md#tests-and-independent-evidence)
for peer defects, the legacy Mapping cipher and GSA's TLS-only response profile.
14 changes: 10 additions & 4 deletions build/dss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cleanup() {
}

inside() {
fixtures_dir=${XMLSEC_DSS_FIXTURE_DIR:-/fixtures}
for tool in java keytool jar go bash timeout sha256sum; do
command -v "$tool" >/dev/null 2>&1 || fail "missing container tool: $tool"
done
Expand All @@ -44,7 +45,7 @@ inside() {
sed -i 's/<Connector port="8080"/<Connector address="127.0.0.1" port="8080"/' "$CATALINA_BASE/conf/server.xml"
grep -q '<Connector address="127.0.0.1" port="8080"' "$CATALINA_BASE/conf/server.xml" || fail 'the expected loopback connector was not configured'
ln -s "$CATALINA_HOME/webapps/ROOT.war" "$CATALINA_BASE/webapps/ROOT.war"
keytool -importcert -noprompt -alias xmlsec-fixture-ca -file "/fixtures/$XMLSEC_DSS_CA_PEM" \
keytool -importcert -noprompt -alias xmlsec-fixture-ca -file "$fixtures_dir/$XMLSEC_DSS_CA_PEM" \
-keystore "$CATALINA_BASE/lib/xmlsec-dss-roots.p12" -storetype PKCS12 -storepass xmlsec-dss-offline
# DSS loads the explicit fixture truststore and properties as classpath resources.
cat > "$CATALINA_BASE/lib/dss-custom.properties" <<'PROPERTIES'
Expand Down Expand Up @@ -82,21 +83,26 @@ PROBE
sleep 1
done
export XMLSEC_DSS_URL=http://127.0.0.1:8080/
export XMLSEC_DSS_FIXTURES="/fixtures/$XMLSEC_DSS_MANIFEST_NAME"
export XMLSEC_DSS_FIXTURES="$fixtures_dir/${XMLSEC_DSS_MANIFEST_NAME:-manifest.json}"
export XMLSEC_DSS_RUNTIME_JAR="$CATALINA_BASE/webapps/ROOT/WEB-INF/lib/dss-validation-$dss_version.jar"
export XMLSEC_REQUIRE_P7_PROOFS=1
# The test checks actual JAR Maven metadata and endpoint version as well as
# exact fixture trust/source identities; the filenames are not version proof.
XMLSEC_DSS_REPORT_DIR=${XMLSEC_DSS_REPORT_DIR:-/tmp/xmlsec-dss-reports}
export XMLSEC_DSS_REPORT_DIR
mkdir -p "$XMLSEC_DSS_REPORT_DIR"
if [ "${1:-}" = all ]; then
export XMLSEC_REQUIRE_P3_PROOFS=1 XMLSEC_REQUIRE_P5_PROOFS=1 XMLSEC_REQUIRE_P6_PROOFS=1
make interop INTEROP_ARGS=-suite=all
return
fi
go run ./tests/cmd/dev proof capture -out "$XMLSEC_DSS_REPORT_DIR/dss.capture.json" -- \
-tags=interop ./tests/interop -run '^TestDSS(Historical|Archive)' -timeout=10m -args -suite=portable
}

if [ "${1:-}" = --inside ]; then
if [ "${1:-}" = --inside ] || [ "${1:-}" = --inside-all ]; then
[ "$#" -eq 1 ] || fail 'unexpected internal arguments'
inside
if [ "$1" = --inside-all ]; then inside all; else inside; fi
exit
fi
case "${1:-}" in ''|--check) ;; *) fail 'usage: sh build/dss.sh [--check]' ;; esac
Expand Down
24 changes: 24 additions & 0 deletions build/interop-inputs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SHA-256, official URL, cache-relative destination. Runtime tests are offline.
5ad3f26cfbb76c94137b79c0ccc35c068b19e209c5f8e32b9787bafb73446e96 https://shibboleth.net/downloads/identity-provider/5.2.3/shibboleth-identity-provider-5.2.3.zip idp.zip
f269b7b98691a48647e54ca5bce9d1042c0eb5f12a0887879974f418f70baa23 https://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-home/12.1.14/jetty-home-12.1.14.tar.gz jetty.tar.gz
1c7db9f726df835349c64edd631de0310eca31291100230064eba153f607b0be https://github.com/Saxonica/Saxon-HE/releases/download/SaxonHE12-10/SaxonHE12-10J.zip saxon.zip
c52862d33cd5bb34ed20d48a5ff62bc475e4279c16fd13460a19f726d1dcf62f https://repo.maven.apache.org/maven2/net/sf/saxon/Saxon-HE/9.4.0-9/Saxon-HE-9.4.0-9.jar saxon20.jar
1b95a61f1f1ee5905898544542e7b283c7780ed63dd6313010c078183d626242 https://www.w3.org/2014/04/xslt-xquery-serialization/schema-for-serialization-parameters.xsd schemas/ser30.xsd
f191b0dc69513670883c0abae97d1dab76965b8bfe3fb0b08a2df1b85d228cd3 https://www.w3.org/2017/01/xslt-xquery-serialization/schema-for-serialization-parameters.xsd schemas/ser31.xsd
34407695050d165be14931c0f378f832d24abe3de682a069d2d6121f07661ec3 https://www.w3.org/TR/2017/REC-xpath-functions-31-20170321/schema-for-json.xsd schemas/json.xsd
c5301a890b0265a705f0806269aa37345aa47d7245a78900b941af65290b16fa https://www.w3.org/TR/2013/REC-xmlenc-core1-20130411/xenc-schema.xsd xmlenc/xenc-schema.xsd
2b48432f036262345638536601d4ea3224897e2d41901163c04eebf350477958 https://www.w3.org/TR/2013/REC-xmlenc-core1-20130411/xenc-schema-11.xsd xmlenc/xenc-schema-11.xsd
5dd57f074870e1d91f7eb814aa92967cefcce9011a86adf5e12a769fcf2a237e https://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd xmlenc/xenc-schema-2002.xsd
35cf8197da812c85e40d57891b35c94187569ed474a2dac813ce5090dafcd35c https://www.w3.org/TR/2008/REC-xmldsig-core-20080610/xmldsig-core-schema.xsd xmlenc/xmldsig-core-schema.xsd
457745286eaa292ae1aaa6e976e0f30eeceb0a37cc2301151576175e0ae1986c https://forge.etsi.org/rep/esi/x19_13201_XAdES/raw/v1.3.1/1913201-XAdES01903v132.xsd xades/1913201-XAdES01903v132.xsd
286bd63f122aafb907c03724c5959455d114020e523631cc22e90c5f5aa667e2 https://forge.etsi.org/rep/esi/x19_13201_XAdES/raw/v1.3.1/1913201-XAdES01903v141.xsd xades/1913201-XAdES01903v141.xsd
6b796f3d4ca40b7917f6e765fbddc9923aa80a7dce68deab2cf7ba8a79c6d7c5 https://www.rfc-editor.org/rfc/rfc9879.txt rfc9879.txt
f0e10bb218795b966824887a8c73b555ab9d88a8e84997882d3e5a807cc9cb37 https://ec.europa.eu/digital-building-blocks/artifact/repository/esignaturedss/eu/europa/ec/joinup/sd-dss/dss-demo-bundle/6.5.1/dss-demo-bundle-6.5.1.zip dss.zip
# Deployed OpenAM SOAP Authority and Google GSA authorization server.
1c8bceab5ec214b92cd2f16b76fd442c3f85483a224db9dcc6417e04a905e2dc https://github.com/OpenIdentityPlatform/OpenAM/releases/download/16.1.4/OpenAM-16.1.4.war openam.war
e04ea07b9cf12c8c06bf520a16d5c546dc3e6a5949fa9ed3ec6a8cbf473ef8cf https://github.com/OpenIdentityPlatform/OpenAM/releases/download/16.1.4/SSOConfiguratorTools-16.1.4.zip openam-configurator.zip
e0f0293ba0fdbcbc52b8554d3ff0b3cba0a59bec0b2f0f1d35b1ea9efdf029a7 https://github.com/OpenIdentityPlatform/OpenAM/releases/download/16.1.4/SSOAdminTools-16.1.4.zip openam-admin.zip
3f53672bfd9ce2a6f3e16ed6b74f8ac2673de812c630feec3e022a89ceb57d24 https://github.com/googlegsa/library/releases/download/v4.1.4/adaptor-4.1.4-withlib.jar gsa-adaptor.jar
408b0e739af1eb8c52734903a4b695db38825d8de8a6543dc918e189d22dc734 https://codeload.github.com/googlegsa/library/zip/refs/tags/v4.1.4 gsa-source.zip

cd62823e5bae65d17ddcf612ec6e57f0aff170ce5abb8bc987f444d759fc6326 https://raw.githubusercontent.com/OpenIdentityPlatform/OpenAM/16.1.4/openam-federation/openam-federation-library/src/main/java/com/sun/identity/saml2/protocol/impl/NameIDMappingResponseImpl.java OpenAM-NameIDMappingResponseImpl.java
53 changes: 52 additions & 1 deletion build/interop.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,58 @@
FROM golang:1.27.3 AS go

FROM debian:forky-slim AS inputs

RUN apt-get update && apt-get install -y --no-install-recommends unzip ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Downloaded by prepare-interop.sh, verified again inside the build.
COPY --from=interop-downloads / /download/
COPY build/interop-inputs.txt /tmp/interop-inputs.txt
RUN awk '!/^#/ && NF {print $1 " /download/" $3}' /tmp/interop-inputs.txt | sha256sum -c - \
&& mkdir -p /opt/opensaml /opt/inputs/saxon \
&& unzip -q /download/idp.zip -d /opt/inputs \
&& unzip -j /download/idp.zip '*/webapp/WEB-INF/lib/*.jar' -d /opt/opensaml \
&& tar -xzf /download/jetty.tar.gz -C /opt/inputs \
&& unzip -q /download/saxon.zip -d /opt/inputs/saxon \
&& unzip -q /download/dss.zip 'dss-demo-bundle-6.5.1/apache-tomcat-11.0.27/*' -d /tmp/dss \
&& mv /tmp/dss/dss-demo-bundle-6.5.1/apache-tomcat-11.0.27 /official-tomcat \
&& cp -R /download/schemas /download/xmlenc /download/xades /opt/inputs/ \
&& cp /download/saxon20.jar /download/rfc9879.txt /opt/inputs/ \
&& cp /opt/inputs/xmlenc/xmldsig-core-schema.xsd /opt/inputs/xades/xmldsig-core-schema-2008.xsd

RUN mkdir -p /opt/inputs/openam/configurator /opt/inputs/openam/admin /opt/inputs/gsa \
&& cp /download/openam.war /opt/inputs/openam/ \
&& cp /download/OpenAM-NameIDMappingResponseImpl.java /opt/inputs/openam/NameIDMappingResponseImpl.java \
&& unzip -q /download/openam-configurator.zip -d /opt/inputs/openam/configurator \
&& unzip -q /download/openam-admin.zip -d /opt/inputs/openam/admin \
&& cp /download/gsa-adaptor.jar /opt/inputs/gsa/ \
&& unzip -q /download/gsa-source.zip 'library-4.1.4/src/com/google/enterprise/adaptor/examples/AdaptorWithCrawlTimeMetadataTemplate.java' -d /opt/inputs/gsa

FROM debian:forky-slim

COPY --from=go /usr/local/go /usr/local/go
COPY --from=inputs /opt/opensaml /opt/opensaml
COPY --from=inputs /opt/inputs /opt/inputs
COPY --from=inputs /official-tomcat /official-tomcat
ENV PATH="/usr/local/go/bin:${PATH}" \
GOTOOLCHAIN=local \
GOPATH=/go
GOPATH=/go \
OPENSAML_CLASSPATH="/opt/opensaml/*" \
SHIBBOLETH_DIST=/opt/inputs/shibboleth-identity-provider-5.2.3 \
JETTY_HOME=/opt/inputs/jetty-home-12.1.14 \
OPENAM_DIST=/opt/inputs/openam \
TOMCAT_HOME=/official-tomcat \
GSA_DIST=/opt/inputs/gsa \
SAXON_CLASSPATH="/opt/inputs/saxon/saxon-he-12.10.jar:/opt/inputs/saxon/lib/*" \
SAXON20_CLASSPATH=/opt/inputs/saxon20.jar \
SERIALIZATION_SCHEMA_DIR=/opt/inputs/schemas \
JSON_SCHEMA_FILE=/opt/inputs/schemas/json.xsd \
XMLENC_SCHEMA_DIR=/opt/inputs/xmlenc \
XADES_SCHEMA_DIR=/opt/inputs/xades \
RFC9879_FILE=/opt/inputs/rfc9879.txt \
XMLSEC_REQUIRE_INTEROP=1 \
XMLSEC_INTEROP_SHARDS=2 \
XMLSEC_INTEROP_PARALLEL=2

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -19,10 +66,14 @@ RUN apt-get update \
openjdk-21-jdk-headless \
openssl \
pkg-config \
patch \
xmlsec1 \
xsltproc \
&& rm -rf /var/lib/apt/lists/*

COPY build/patch-openam.sh build/openam-nameid-order.patch /opt/inputs/openam/
RUN sh /opt/inputs/openam/patch-openam.sh /opt/inputs/openam /opt/inputs/openam/openam-nameid-order.patch

WORKDIR /workspace
COPY go.mod go.sum ./
RUN go mod download && go mod verify
Expand Down
Loading
Loading