使用JNA获得本地计算机证书 [英] Use JNA to get Local machine Certificate

查看:234
本文介绍了使用JNA获得本地计算机证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从本地计算机Windows存储获取证书.想要获得的是位于证书(本地计算机)->个人->证书"中的证书.

I'm trying to get a certificate from local machine Windows store. What a want to get is a certificate in the patth "Certificates(Local Computer) --> Personal --> Certificates".

我使用此代码在证书-当前用户->个人->证书

I used this code to access certificate in the path "Certificates - Current User --> Personal --> Certificates

 NativeLibrary crypt32 = NativeLibrary.getInstance("Crypt32");
 Function functionCertOpenSystemStore = 
 crypt32.getFunction("CertOpenSystemStoreA");
 Object[] argsCertOpenSystemStore = new Object[] { 0, "MY"};
HANDLE h = (HANDLE) functionCertOpenSystemStore.invoke(HANDLE.class, argsCertOpenSystemStore);

关于如何从证书(本地计算机)->个人->证书"中获取证书的任何想法?

Any idea about how to get a certificate from "Certificates(Local Computer) --> Personal --> Certificates"?

我正在尝试使用JNA,因为我无法读取以从Java访问本地计算机证书.我唯一需要做的就是使用这样的密钥库来获取当前用户"证书:

I'm trying to use JNA because I read is not posible to access local machine certificates from Java. I only thing I've got is to get "Current user" certificates using keystore like this :

KeyStore ks = KeyStore.getInstance("Windows-MY", "SunMSCAPI");

我也尝试过这个:

KeyStore ks = KeyStore.getInstance("Windows-ROOT", "SunMSCAPI");

有人可以给我一个线索吗?

Can someone give me a clue?

推荐答案

是的,您可以使用 wcsa实用程序,它将拦截对Windows Crypto API的调用,并允许您访问本地计算机凭据.当然,这是针对实际问题的破解, JDK-6782021 是十年前报道的.但这确实使您可以轻松访问本地计算机证书!

Yes, you can use the wcsa utility, which will intercept calls to the Windows Crypto API and let you access the local machine credentials. This is of course a hack around the real problem, JDK-6782021, which was reported ten years ago. But it does let you access the local machine certificates in a pretty painless way!

这篇关于使用JNA获得本地计算机证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆