Using multiple SSL client certificates in Java with the same host

前端 未结 3 1217
孤城傲影
孤城傲影 2020-12-29 15:42

In my Java application, I need to connect to the same host using SSL, but using a different certificate each time. The reason I need to use different certificates is that t

3条回答
  •  遥遥无期
    2020-12-29 16:02

    Implementations may have changed a lot since the question was asked. My understanding is that the server will send trusted issues to the client:

    Found trusted certificate:
    [
    [
      Version: V3
      Subject: CN=localhost, OU=Spring, O=Pivotal, L=Holualoa, ST=HI, C=US
      Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11
    

    Then the client will receive a CertificateRequest:

    *** CertificateRequest
    Cert Types: RSA, DSS, ECDSA
    Supported Signature Algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA256withDSA, SHA224withECDSA, SHA224withRSA, SHA224withDSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA
    Cert Authorities:
    
    

    Then the client will scan its local keystore with issuers:

    Set certIssuers =
                            credentials.getIssuerX500Principals();
    for (int i = 0; i < x500Issuers.length; i++) {
        if (certIssuers.contains(issuers[i])) {
            aliases.add(alias);
            if (debug != null && Debug.isOn("keymanager")) {
                System.out.println("matching alias: " + alias);
            }
            break;
        }
    

    If found, it will use that certificate.

提交回复
热议问题