How to sign data with .p12 file in Java?
Asked Answered
E

2

6

How to sign data with .p12 file in Java?

Java seems to support only until pkcs11, I just can't find the standard library for pkcs12. There's nothing in 'java.security'... for decoding .p12 file to get private key to perform signing.

Any solution? I'm creating an applet so it's good if there's a small library available, but not those libraries of 1MB or above.

Epifocal answered 2/12, 2011 at 14:26 Comment(1)
pkcs11 is for signing with usb token, pkcs12 is for signing with p12 fileEpifocal
L
4

You can open an p12 file as a keystore.

http://docs.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#KeystoreFormats

After opening the keystore you can retrieve the private key and use it for signing your data.

Labiodental answered 2/12, 2011 at 16:8 Comment(1)
tks, i also found it: java.security.KeyStore.getInstance("PKCS12");Epifocal
D
-1

I've posted a clean, working solution for using .p12 / pkcs12 certificates in Java in another StackOverflow answer here.

Drillstock answered 14/9, 2016 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.