Skip to content
A PHP library for XML Security
Branch: master
Clone or download
Latest commit 0f54660 Jan 3, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests Merge remote-tracking branch 'thijskh/tests/fix-verify-return-code-ch… Jul 13, 2017
.gitattributes [git] Add .gitattributes to remove unneeded files Nov 17, 2016
.gitignore [git] Ignore composer.lock and vendor folder Jun 11, 2015
.travis.yml test for PHP 7.3 as well Oct 18, 2018
CHANGELOG.txt Back to dev Nov 15, 2018
LICENSE prep 3.0.2 release Sep 27, 2018 No longer supporting 2.x branch Nov 15, 2018
xmlseclibs.php Update year Jan 3, 2019


xmlseclibs is a library written in PHP for working with XML Encryption and Signatures.

The author of xmlseclibs is Rob Richards.


Master is currently the only actively maintained branch.

  • master: Removes mcrypt usage requiring 5.4+ (5.6.24+ recommended for security reasons)
  • 2.0: Contains namespace support requiring 5.3+
  • 1.4: Contains auto-loader support while also maintaining backwards compatiblity with the older 1.3 version using the xmlseclibs.php file. Supports PHP 5.2+


xmlseclibs requires PHP version 5.4 or greater. 5.6.24+ recommended for security reasons

How to Install

Install with composer.phar.

php composer.phar require "robrichards/xmlseclibs"

Use cases

xmlseclibs is being used in many different software.

Basic usage

The example below shows basic usage of xmlseclibs, with a SHA-256 signature.

use RobRichards\XMLSecLibs\XMLSecurityDSig;
use RobRichards\XMLSecLibs\XMLSecurityKey;

// Load the XML to be signed
$doc = new DOMDocument();

// Create a new Security object 
$objDSig = new XMLSecurityDSig();
// Use the c14n exclusive canonicalization
// Sign using SHA-256

// Create a new (private) Security key
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type'=>'private'));
If key has a passphrase, set it using
$objKey->passphrase = '<passphrase>';
// Load the private key
$objKey->loadKey('./path/to/privatekey.pem', TRUE);

// Sign the XML file

// Add the associated public key to the signature

// Append the signature to the XML
// Save the signed XML

How to Contribute

Mailing List:!forum/xmlseclibs

You can’t perform that action at this time.