Skip to content

m-ovs/php-digidoc

 
 

Repository files navigation

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.

About

A DigiDoc library for signing documents

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%