Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

双向验证时,客户端应该使用何种证书? #876

Closed
ckz119 opened this issue Oct 10, 2024 · 4 comments
Closed

双向验证时,客户端应该使用何种证书? #876

ckz119 opened this issue Oct 10, 2024 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@ckz119
Copy link

ckz119 commented Oct 10, 2024

如果是双向验证的话,tongsuo的客户端证书是加载加密证书还是签名证书?
加上客户端验证后,加载tongsuo项目提供的客户端签名证书和签名秘钥但是报错,错误信息:
image

加载客户端代码:
image

@johnshajiang johnshajiang changed the title @ckz119 双向验证时,客户端应该使用何种证书? Oct 10, 2024
@johnshajiang
Copy link
Collaborator

如果是双向验证的话,tongsuo的客户端证书是加载加密证书还是签名证书?

对于TLCP协议,我以为客户端也应该提供两个证书。

@meteor199
Copy link

也要两个证书。可以在 https://www.gmcrt.cn/gmcrt/index.jsp 生成测试证书。

keystore引入


        KeyStore keyStore = createStore();
        try (FileInputStream keyStoreIn = new FileInputStream(
                Paths.get(dirPath+"/clientKeystore.jks").toFile())) {
            keyStore.load(keyStoreIn, PASSWORD.toCharArray());
        }
        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509", "Kona");
        kmf.init(keyStore, PASSWORD.toCharArray());

keystore生成


%JAVA_PATH% -cp ./jar/* com.tencent.kona.pkix.tool.KeyStoreTool ^
  -type JKS ^
  -alias enc ^
  -keyAlgo EC ^
  -key %CLIENT_PATH%/enc.key ^
  -certs %CLIENT_PATH%/enc.cer ^
  -store ./output/clientKeystore.jks ^
  -keyPasswd 123123 ^
  -storePasswd 123123 

echo "key store enc success"

@REM 生成keystore
%JAVA_PATH% -cp ./jar/* com.tencent.kona.pkix.tool.KeyStoreTool ^
  -type JKS ^
  -alias sig ^
  -keyAlgo EC ^
  -key %CLIENT_PATH%/sig.key ^
  -certs %CLIENT_PATH%/sig.cer ^
  -store ./output/clientKeystore.jks ^
  -keyPasswd 123123  ^
  -storePasswd 123123 

echo "key store sig success"

@ckz119
Copy link
Author

ckz119 commented Oct 17, 2024

也要两个证书。可以在 https://www.gmcrt.cn/gmcrt/index.jsp 生成测试证书。

keystore引入


        KeyStore keyStore = createStore();
        try (FileInputStream keyStoreIn = new FileInputStream(
                Paths.get(dirPath+"/clientKeystore.jks").toFile())) {
            keyStore.load(keyStoreIn, PASSWORD.toCharArray());
        }
        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509", "Kona");
        kmf.init(keyStore, PASSWORD.toCharArray());

密钥库生成


%JAVA_PATH% -cp ./jar/* com.tencent.kona.pkix.tool.KeyStoreTool ^
  -type JKS ^
  -alias enc ^
  -keyAlgo EC ^
  -key %CLIENT_PATH%/enc.key ^
  -certs %CLIENT_PATH%/enc.cer ^
  -store ./output/clientKeystore.jks ^
  -keyPasswd 123123 ^
  -storePasswd 123123 

echo "key store enc success"

@REM 生成keystore
%JAVA_PATH% -cp ./jar/* com.tencent.kona.pkix.tool.KeyStoreTool ^
  -type JKS ^
  -alias sig ^
  -keyAlgo EC ^
  -key %CLIENT_PATH%/sig.key ^
  -certs %CLIENT_PATH%/sig.cer ^
  -store ./output/clientKeystore.jks ^
  -keyPasswd 123123  ^
  -storePasswd 123123 

echo "key store sig success"

非常感谢你!

@johnshajiang
Copy link
Collaborator

@ckz119
如果该问题已经得到解答,请关闭该issue。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants