Digitally Sign request with PHP

80 Views Asked by At

I have a request to the API that needs to be signed with an electronic signature. I have an openssl command that generates this signature.

openssl cms -noattr -sign -binary -nosmimecap -no certs -signed my.crt -key my.key -outform der -in digest.txt -out digest.sign

Detailed description of the command:

# Basic command signature generation via openssl
`openssl cms -sign \`
# Electronic signature certificate, key, digest
`-signer my.crt -key my.key -outform der -in digest.txt -out digest.sign \`
# Removes attributes such as signing time and content type from inclusion
`--no matter \`
# Removes attributes such as the list of supported algorithms from inclusion
`-nosmimecap \`
# Removes line breaks of CR and LF
`-binary format from inclusion \`
# Removes the signer's certificate from inclusion
`-nocerts`

As far as I understand in PHP, you can use phpseclib for this. How do I get a result similar to a console command in a PHP variable?

I am not familiar with cryptography, reading the documentation at the moment did not help me

0

There are 0 best solutions below