Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can SSL cert be used to digitally sign files?

I want to ask a thing about digital signing I am not very sure. Instead of creating a self signed certificate to use to sign some (PDF) files, I wanted to take my SSL cert which have my data already verified.

But the question is: Can a SSL cert be used to digital sign files or is it incompatible in some manner?

EDIT: To clarify, this question is not about how to sign PDFs, is only about if a SSL cert can be used (or converted in any way) to sign files.

like image 262
StormByte Avatar asked Mar 13 '12 20:03

StormByte


People also ask

Can SSL certificate be used for digital signature?

A digital signature is formed by encrypting a representation of a message. The encryption uses the private key of the signatory and, for efficiency, usually operates on a message digest rather than the message itself.

Is SSL certificate A digital certificate?

To create this secure connection, an SSL certificate (also referred to as a “digital certificate”) is installed on a web server and serves two functions: It authenticates the identity of the website (this guarantees visitors that they're not on a bogus site) It encrypts the data that's being transmitted.

What can you do with an SSL certificate?

An SSL certificate is a bit of code on your web server that provides security for online communications. When a web browser contacts your secured website, the SSL certificate enables an encrypted connection. It's kind of like sealing a letter in an envelope before sending it through the mail.

Is a code signing certificate same as SSL?

Code signing certificate is used for securing software while SSL certificate is used for securing internet communication. But the issuing authority of certificates can be same for both kinds. In both the cases, a pair of public and private keys are used to encrypt or hash the software or the communication path.


2 Answers

To support digital signing certificate must have digitalSignature option in it's keyUsage field (and codeSigning option in it's extendedKeyUsage field if your want to sign programs with it).

Signing may be done with existing tools or manually (java example, you are not asking for it, but this code snippet might be useful anyway):

byte[] bytesToSign = loadMyData();
KeyStore ks = KeyStore.getInstance("pkcs12", "SunJSSE");
ks.load(new FileInputStream("cert.p12"), "passwd1".toCharArray());
PrivateKey privateKey = (PrivateKey) ks.getKey("myalias", "passwd2".toCharArray());
Signature sig = Signature.getInstance("SHA1withRSA", ks.getProvider());
sig.initSign(privateKey);
sig.update(bytesToSign);
byte[] signature = sig.sign();

To make your own not self-signed certificate with openssl see this SO answer.

Also curious about signing PDF's - aren't separate hash sums of these files enough in your case?

edit: if you want any sign, not exactly X.509 sign by existing tools, you can extract RSA key from your cert and do signing without bothering about keyUsage field.

like image 98
alexkasko Avatar answered Oct 13 '22 01:10

alexkasko


At the core, the certificate is just a normal RSA public key that's been signed by several authorities.

So yes, definitely possible.

Though I don't know of any easy-to-use widespread tools for the end-user for this.

like image 33
Deestan Avatar answered Oct 12 '22 23:10

Deestan