Skip to content

Commit 38b74ce

Browse files
authored
bugfix: ARI: OpenSSL 'authorityKeyIdentifier' (#54)
"keyid" prefix not present anymore in newer openssl versions
1 parent e8e5d0d commit 38b74ce

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ACMECert
22

33
PHP client library for [Let's Encrypt](https://letsencrypt.org/) and other [ACME v2 - RFC 8555](https://tools.ietf.org/html/rfc8555) compatible Certificate Authorities.
4-
Version: 3.4.0
4+
Version: 3.4.1
55

66
## Description
77

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "skoerfgen/acmecert",
3-
"version": "3.4.0",
3+
"version": "3.4.1",
44
"description": "PHP client library for Let's Encrypt and other ACME v2 - RFC 8555 compatible Certificate Authorities",
55
"license": "MIT",
66
"authors": [

src/ACMECert.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,19 +471,24 @@ private function getARICertID($pem){
471471
if (version_compare(PHP_VERSION,'7.1.2','<')){
472472
throw new Exception('PHP Version >= 7.1.2 required for ARI'); // serialNumberHex - https://github.com/php/php-src/pull/1755
473473
}
474+
474475
$ret=$this->parseCertificate($pem);
475476

476477
if (!isset($ret['extensions']['authorityKeyIdentifier'])) {
477478
throw new Exception('authorityKeyIdentifier missing');
478479
}
479-
$aki=hex2bin(str_replace(':','',substr(trim($ret['extensions']['authorityKeyIdentifier']),6)));
480+
481+
$aki=trim($ret['extensions']['authorityKeyIdentifier']);
482+
if (stripos($aki,'keyid')===0) $aki=substr($aki,5);
483+
$aki=hex2bin(str_replace(':','',$aki));
480484
if (!$aki) throw new Exception('Failed to parse authorityKeyIdentifier');
481485

482486
if (!isset($ret['serialNumberHex'])) {
483487
throw new Exception('serialNumberHex missing');
484488
}
485489
$ser=hex2bin(trim($ret['serialNumberHex']));
486490
if (!$ser) throw new Exception('Failed to parse serialNumberHex');
491+
if (ord($ser[0]) & 0x80) $ser="\x00".$ser;
487492

488493
return $this->base64url($aki).'.'.$this->base64url($ser);
489494
}

src/ACMEv2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ protected function http_request($url,$data=null){
309309
}
310310

311311
$method=$data===false?'HEAD':($data===null?'GET':'POST');
312-
$user_agent='ACMECert v3.4.0 (+https://github.com/skoerfgen/ACMECert)';
312+
$user_agent='ACMECert v3.4.1 (+https://github.com/skoerfgen/ACMECert)';
313313
$header=($data===null||$data===false)?array():array('Content-Type: application/jose+json');
314314
if ($this->ch) {
315315
$headers=array();

0 commit comments

Comments
 (0)