Digital Signature SunMSCAPI provider & MS Crypto API

前端 未结 1 1526
我在风中等你
我在风中等你 2020-12-18 09:39

I want to sign file with the SunMSCAPI provider. As public key and signatures needs to be imported using MS Crypto API.

Generally generating signatures

相关标签:
1条回答
  • 2020-12-18 09:56

    If you work with MSCAPI, it is assumed that you've added your key to the Microsoft Certificate store. You can check if the key is present by going to "Internet Properties" > "Content" > "Certificates" which gives you a list of certificates that are available. If your certificate isn't there, you can't use it. If it's there, you need this code:

    SunMSCAPI providerMSCAPI = new SunMSCAPI();
    Security.addProvider(providerMSCAPI);
    KeyStore ks = KeyStore.getInstance("Windows-MY");
    ks.load(null, null);
    

    From there on, the code is pretty standard. Please consult my book on digital signatures for more info (the book is free).

    IMPORTANT ADDITION: I forgot to mention that SunMSCAPI isn't present in the 64-bit version of Java 6 (I don't know about Java 7). You can fix this by installing the 32-bit version.

    0 讨论(0)
提交回复
热议问题