dealfonso / sapp

Simple and Agnostic PDF Document Parser in PHP - sign PDF docs using PHP
GNU Lesser General Public License v3.0
110 stars 29 forks source link

On windows i get `openssl_pkcs7_sign(): Error getting private key` #48

Closed parallels999 closed 1 year ago

parallels999 commented 1 year ago

On linux everything works, but on windows not After debugging i found the problem here, $t_decpkey is null, and openssl_error_string() is error:2006D080:BIO routines:BIO_new_file:no such file https://github.com/dealfonso/sapp/blob/3d7f18a5c1f75f7f4b3b5773492487e78af2fc94/src/PDFDoc.php#L296-L301 image any ideas??

dealfonso commented 1 year ago

Hi,

I do not have access to any Windows... but it seems a problem with your OpenSSL configuration. Please check that OpenSSL is properly configured in your installation, and you are able to use it from PHP.

parallels999 commented 1 year ago

Please check that OpenSSL is properly configured in your installation

I'm using xampp, i check it, and $t_decpkey is not null now, but now i'm getting

error:0909006C:PEM routines:get_name:no start line
error:0909006C:PEM routines:get_name:no start line
error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
error:23077074:PKCS12 routines:PKCS12_pbe_crypt:pkcs12 cipherfinal error
error:2306A075:PKCS12 routines:PKCS12_item_decrypt_d2i:pkcs12 pbe crypt error
error:0907B00D:PEM routines:PEM_read_bio_PrivateKey:ASN1 lib
error:0909006C:PEM routines:get_name:no start line
error:0909006C:PEM routines:get_name:no start line

image

dealfonso commented 1 year ago

Hi,

googling a bit, it seems that it has to do with your pem file.

https://stackoverflow.com/questions/74842756/php-laravel-openssl-error0909006cpem-routinesget-nameno-start-line

Maybe it has to do with Windows CRLF.