@@ -50,15 +50,31 @@ public function testConstructWithEmptyContent(): void
5050
5151 public function testConstructWithInvalidContent (): void
5252 {
53- $ this ->expectException (UnexpectedValueException ::class);
54- $ this ->expectExceptionMessage ('Private key is not PEM ' );
53+ $ this ->expectException (RuntimeException ::class);
54+ $ this ->expectExceptionMessage ('Cannot open private key ' );
5555 new PrivateKey ('invalid content ' , '' );
5656 }
5757
5858 public function testConstructWithInvalidButBase64Content (): void
5959 {
60- $ this ->expectException (UnexpectedValueException ::class);
61- $ this ->expectExceptionMessage ('Private key is not PEM ' );
60+ $ this ->expectException (RuntimeException ::class);
61+ $ this ->expectExceptionMessage ('Cannot open private key ' );
6262 new PrivateKey ('INVALID+CONTENT ' , '' );
6363 }
64+
65+ public function testConstructWithPkcs8Content (): void
66+ {
67+ $ content = $ this ->fileContents ('CSD01_AAA010101AAA/private_key.key ' );
68+ $ password = trim ($ this ->fileContents ('CSD01_AAA010101AAA/password.txt ' ));
69+ $ privateKey = new PrivateKey ($ content , $ password );
70+ $ this ->assertGreaterThan (0 , $ privateKey ->numberOfBits ());
71+ }
72+
73+ public function testConstructWithPkcs8Base64Content (): void
74+ {
75+ $ content = base64_encode ($ this ->fileContents ('CSD01_AAA010101AAA/private_key.key ' ));
76+ $ password = trim ($ this ->fileContents ('CSD01_AAA010101AAA/password.txt ' ));
77+ $ privateKey = new PrivateKey ($ content , $ password );
78+ $ this ->assertGreaterThan (0 , $ privateKey ->numberOfBits ());
79+ }
6480}
0 commit comments