P
P
pcmyonelove2021-06-02 23:16:40
PHP
pcmyonelove, 2021-06-02 23:16:40

How to parse data from a certificate in a signed file with a public key?

I was given (as was said) a simple task of parsing a certificate from a file, but after thoughtful googling, I ask you to help the young jun, in practice everything turned out to be a little less than difficult -_-
So, initially I was given two files test.pdf.sig and sert.cer. I found a mention of the ViPNet SCP crypto provider in the certificate and they have the ViPNet CryptoFile utility that somehow signs the files. We need to extract the data from the certificate that is inside the signed test.pdf.sig file. I tried to use OpenSSL and phpseclib, it turned out only to parse the certificate itself and get the publicKey as a string.
I found out that the signature in the file is called PKCS9 (or PKCS7but regex didn't find the right bytes) and some ASN1 format . And here everything became much more complicated, I could not find a good manual on how to do it right.
As I understood from googling, you need to extract this signature from the file, then unpack it, read the last certificate, and parse the data from it. But here's how to extract this signature in PHP or through the console?

File signing software
LBc8xsp.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexdob, 2021-06-11
@alexdob

I advise you to google in the direction of "PHP detached signature"
the crypto-pro seems to have an extension for PHP, but I personally have not tried it..
cpdn.cryptopro.ru/?url=/content/cades/phpcades.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question