To support a digital signature certificate, there must be a digitalSignatureparameter keyUsage(s codeSigning) in it extendedKeyUsageif you want to sign programs with it).
Signing can be performed using existing tools or manually (java example, you do not request it, but this piece of code can be useful in any case):
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 self-signed certificate with openssl see this SO answer .
It’s also interesting to know about signing a PDF - aren’t the individual hash amounts of these files enough in your case?
edit: if you want a character, not just an X.509 character using existing tools, you can extract the RSA key from your certificate and sign up without worrying about the field keyUsage.
source
share