@@ -19,14 +19,15 @@ private function handleResult(string $command, $iResult, int $iErrorCode = null,
19
19
{
20
20
if (!empty ($ iErrorCode ) && !in_array ($ iErrorCode , $ aAcceptableErrorCodes )) {
21
21
euspe_geterrdescr ($ iErrorCode , $ sErrorDescription );
22
+ $ utfEncoding = 'utf-8 ' ;
22
23
throw new Exception (
23
24
sprintf (
24
25
'Result: %s Code: %s Command: %s Error: %s. Check error in EUSignConsts.php by code. ' ,
25
26
dechex ($ iResult ),
26
27
dechex ($ iErrorCode ),
27
28
$ command ,
28
- ($ encoding = mb_detect_encoding ($ sErrorDescription )) && $ encoding !== ' UTF-8 ' ?
29
- mb_convert_encoding ($ sErrorDescription , $ encoding , ' utf-8 ' ) :
29
+ ($ encoding = mb_detect_encoding ($ sErrorDescription )) && strtolower ( $ encoding) !== $ utfEncoding ?
30
+ mb_convert_encoding ($ sErrorDescription , $ encoding , $ utfEncoding ) :
30
31
$ sErrorDescription
31
32
)
32
33
);
@@ -242,29 +243,4 @@ function envelopData(string $data, array $certs): string
242
243
// TODO: Implement envelopData() method.
243
244
return '' ;
244
245
}
245
-
246
- public static function getInstanceClient (string $ secretToken , KeyRingStorage $ keyRingStorage , User $ user , bool $ hasCerts ): ?self
247
- {
248
- $ client = new self ();
249
- $ client ->open ();
250
- $ keyRing = $ keyRingStorage ->prepare ($ user );
251
- if (!$ keyRingStorage ->exists ($ keyRing )) {
252
- $ keyRing ->setPassword ($ user ->getPassword ());
253
- $ keyRing ->setType ($ user ->getKeyType ());
254
- if ($ keyRing ->typeIsDAT ()) {
255
- $ keyRing ->setPrivateKeys ([$ user ->getKeyData ()]);
256
- } else {
257
- $ keyRing ->setPrivateKeys ($ client ->retrieveJKSPrivateKeys ($ user ->getKeyData ()));
258
- }
259
- $ keyRingStorage ->store ($ keyRing , $ secretToken );
260
- }
261
- $ keyRingStorage ->load ($ keyRing , $ secretToken );
262
- if (!$ hasCerts ) {
263
- foreach ($ keyRing ->getPrivateKeys () as $ privateKey ) {
264
- $ client ->readPrivateKey ($ privateKey , $ keyRing ->getPassword ());
265
- $ client ->resetPrivateKey ();
266
- }
267
- }
268
- return $ client ;
269
- }
270
246
}
0 commit comments