A DigiDoc library for signing documents
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE
README.md
UPGRADE.md
composer.json
phpunit.xml.dist

README.md

PHP DigiDoc

Build Status

PHP DigiDoc is a PHP library for digitally signing and verifying digital signatures using estonian id cards.

Usage

<?php

use KG\DigiDoc\Api;
use KG\DigiDoc\Client;

// This file is generated by Composer
require_once 'vendor/autoload.php';

$api = new Api(new Client());

// First off, let's create a new envelope.
$envelope = $api->create();

// Add the files you want to get signed.
$envelope->addFile('/path/to/file.txt');
$envelope->addFile('/second/path/to/file.md');

// Add a signature or two. Signature takes in certificate id and certificate
// signature. You must retrieve these from the client using the browser plugin.
$envelope->addSignature($signature = new Signature('F1..20', '8F..C0'));

// Sync up with the server. For example, the previous signature is given
// a challenge, which the client must solve.
$api->update($envelope);

printf("Challenge: %s\n", $signature->getChallenge());

// Set the solution for the given signature. This is computed by the borwser
// plugin.
$signature->setSolution('F6..00');

// Sync up with the server once more to send the solution.
$api->update($envelope);

// Time to write it on the disc.
$api->write('/tmp/my-newly-created-envelope.bdoc');

// Make sure to "close" the envelope (basically closes the session in the
// remote DigiDoc service).
$api->close($envelope);

Installation

Install using Composer as kgilden/php-digidoc.

Requirements

  • PHP >= 5.3.8
  • (php-soap, if you're on a Debian based distro)

Contributing

See CONTRIBUTING.md file.

Running the Tests

It's as simple as running phpunit.

License

PHP DigiDoc is released under the MIT License. See the bundled LICENSE file for details.