Skip to content

Commit 87c9053

Browse files
committed
Add Certificate::issuerAsRfc4514() used in XML SEC
1 parent 953f43d commit 87c9053

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Certificate.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,10 @@ protected function createSerialNumber(string $hexadecimal, string $decimal): Ser
219219
}
220220
throw new UnexpectedValueException('Certificate does not contain a serial number');
221221
}
222+
223+
public function issuerAsRfc4514(): string
224+
{
225+
$issuer = $this->issuer();
226+
return (new Internal\Rfc4514())->escapeArray($issuer);
227+
}
222228
}

tests/Unit/CertificateTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,25 @@ public function testIssuerData(): void
8282
$this->assertSame('SAT970701NN3', $certificate->issuerData('x500UniqueIdentifier'));
8383
}
8484

85+
public function testIssuerAsRfc4514(): void
86+
{
87+
$certificate = $this->createCertificate();
88+
$expected = [
89+
'CN=A.C. 2 de pruebas(4096)',
90+
'O=Servicio de Administración Tributaria',
91+
'OU=Administración de Seguridad de la Información',
92+
93+
'street=Av. Hidalgo 77\2c Col. Guerrero', // see how it was encoded
94+
'postalCode=06300',
95+
'C=MX',
96+
'ST=Distrito Federal',
97+
'L=Coyoacán',
98+
'x500UniqueIdentifier=SAT970701NN3',
99+
'unstructuredName=Responsable: ACDMA',
100+
];
101+
$this->assertEquals($expected, explode(',', $certificate->issuerAsRfc4514()));
102+
}
103+
85104
public function testPublicKey(): void
86105
{
87106
$certificate = $this->createCertificate();

0 commit comments

Comments
 (0)