Subversion Repositories oidplus

Rev

Rev 1050 | Go to most recent revision | Last modification | View Log | RSS feed

Last modification

Path Last modification Log RSS
[NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE] [DIRECTORY] src/ 868  2022-07-09 21:33:15 daniel-marschall Log RSS
[NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE] [DB-FILE] CHANGELOG.txt 868  2022-07-09 21:33:15 daniel-marschall Log RSS
[NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE] [FILE] composer.json 868  2022-07-09 21:33:15 daniel-marschall Log RSS
[NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE] [FILE] LICENSE 868  2022-07-09 21:33:15 daniel-marschall Log RSS
[NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE] [FILE] README.md 868  2022-07-09 21:33:15 daniel-marschall Log RSS
[NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE][NODE] [DB-FILE] xmlseclibs.php 868  2022-07-09 21:33:15 daniel-marschall Log RSS

xmlseclibs

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

The author of xmlseclibs is Rob Richards.

Branches

Master is currently the only actively maintained branch.

Requirements

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();

$doc->load('./path/to/file/tobesigned.xml');

// Create a new Security object

$objDSig = new XMLSecurityDSig();

// Use the c14n exclusive canonicalization

$objDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);

// Sign using SHA-256

$objDSig->addReference(

$doc, 
XMLSecurityDSig::SHA256, 
array('http://www.w3.org/2000/09/xmldsig#enveloped-signature')

);

// 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 = '';

*/

// Load the private key

$objKey->loadKey('./path/to/privatekey.pem', TRUE);

// Sign the XML file

$objDSig->sign($objKey);

// Add the associated public key to the signature

$objDSig->add509Cert(file_get_contents('./path/to/file/mycert.pem'));

// Append the signature to the XML

$objDSig->appendSignature($doc->documentElement);

// Save the signed XML

$doc->save('./path/to/signed.xml');

How to Contribute

Mailing List: https://groups.google.com/forum/#!forum/xmlseclibs