How to load multiple SSL certificates in Java KeyStore?


Peter

I have two SSL certificate files. The first is labeled "OU=Certificate Authority" and the second is labeled "OU=Root Certificate". Our C++ application loads both certificates for proper client/server handshake.

Now, I need to use these certificates in my Android code. I have been able to successfully read these certificates using the CertificateFactory.generateCertificate()method .

Next, I need to store these certificates in the keystore. Here is the sample code I found:

    String keyStoreType = KeyStore.getDefaultType();
    KeyStore keyStore = KeyStore.getInstance(keyStoreType);
    keyStore.load(null, null);
    keyStore.setCertificateEntry("ca", ca);

I am confused about how to store the root certificate. Do I setCertificateEntry()ask for a second certificate again and pass some random alias?

I saw another method on KeyStore called setEntry. Should I use this method instead? greeting.

username

Just call it again with another alias.

example:

keyStore.setCertificateEntry("ca", ca);
keyStore.setCertificateEntry("debug", ca2);

Related


How to load multiple SSL certificates in Java KeyStore?

Peter I have two SSL certificate files. The first is labeled "OU=Certificate Authority" and the second is labeled "OU=Root Certificate". Our C++ application loads both certificates for proper client/server handshake. Now, I need to use these certificates in my

How to load multiple SSL certificates in Java KeyStore?

Peter I have two SSL certificate files. The first is labeled "OU=Certificate Authority" and the second is labeled "OU=Root Certificate". Our C++ application loads both certificates for proper client/server handshake. Now, I need to use these certificates in my

Can we load multiple certificates and keys in keystore?

Jay Chou: Can we load multiple certificates and keys in keystore? Is it always necessary to load only the pair (i.e. certificate and key together)? If the keystore has multiple certificates and keys, which certificate and key will be chosen when Java SSL tries

Can we load multiple certificates and keys in keystore?

Jay Chou: Can we load multiple certificates and keys in keystore? Is it always necessary to load only the pair (i.e. certificate and key together)? If the keystore has multiple certificates and keys, when Java SSL tries to establish a connection as a server, w

Can we load multiple certificates and keys in keystore?

Jay Chou: Can we load multiple certificates and keys in keystore? Is it always necessary to load only the pair (i.e. certificate and key together)? If the keystore has multiple certificates and keys, when Java SSL tries to establish a connection as a server, w

Can we load multiple certificates and keys in keystore?

Jay Chou: Can we load multiple certificates and keys in keystore? Is it always necessary to load only the pair (i.e. certificate and key together)? If the keystore has multiple certificates and keys, which certificate and key will be chosen when Java SSL tries

How to have multiple SSL certificates for Java server

Lawrence Dol: I have an internal HTTP server written in Java; the full source code is at my disposal. The HTTP server can be configured with any number of websites, each with a separate listening socket, which is created with the following command: skt=SSLServ

How to have multiple SSL certificates for Java server

Lawrence Dol: I have an internal HTTP server written in Java; the full source code is at my disposal. The HTTP server can be configured with any number of websites, each with a separate listening socket, which is created with the following command: skt=SSLServ

How to have multiple SSL certificates for Java server

Lawrence Dol: I have an internal HTTP server written in Java; the full source code is at my disposal. The HTTP server can be configured with any number of websites, each with a separate listening socket, which is created with the following command: skt=SSLServ

Convert pem with multiple certificates to java keystore

Richie I got a pem file with two certificates in it. The first is that the certificate is specific to my company (i.e. the subject is specific to my company). The second certificate is the issuer's certificate. It looks like this... Bag Attributes localKey

Configure Multiple SSL Certificates on Application Load Balancer

qdequippe I want to configure multiple ssl certificates for the application load balancer directly in my eb extension file, but cannot set multiple ARNs under my configuration: - namespace: aws:elbv2:listener:443 option_name: SSLCertificateArns value: 'arn

Configure Multiple SSL Certificates on Application Load Balancer

qdequippe I want to configure multiple ssl certificates for the application load balancer directly in my eb extension file, but cannot set multiple ARNs under my configuration: - namespace: aws:elbv2:listener:443 option_name: SSLCertificateArns value: 'arn

Configure Multiple SSL Certificates on Application Load Balancer

qdequippe I want to configure multiple ssl certificates for the application load balancer directly in my eb extension file, but cannot set multiple ARNs under my configuration: - namespace: aws:elbv2:listener:443 option_name: SSLCertificateArns value: 'arn

Exchange SSL certificates in MQ keystore

username I am trying to establish an SSL connection between two MQ servers. In both certificates, I use self-signed certificates, I created one certificate for QM_A (sender) and another certificate for QM_V (receiver). Since the connection will be a "one-way m

Exchange SSL certificates in MQ keystore

username I am trying to establish an SSL connection between two MQ servers. In both certificates, I use self-signed certificates, I created one certificate for QM_A (sender) and another certificate for QM_V (receiver). Since the connection will be a "one-way m

Exchange SSL certificates in MQ keystore

username I am trying to establish an SSL connection between two MQ servers. In both certificates, I use self-signed certificates, I created one certificate for QM_A (sender) and another certificate for QM_V (receiver). Since the connection will be a "one-way m

Exchange SSL certificates in MQ keystore

username I am trying to establish an SSL connection between two MQ servers. In both certificates, I use self-signed certificates, I created one certificate for QM_A (sender) and another certificate for QM_V (receiver). Since the connection will be a "one-way m

Exchange SSL certificates in MQ keystore

username I am trying to establish an SSL connection between two MQ servers. In both certificates, I use self-signed certificates, I created one certificate for QM_A (sender) and another certificate for QM_V (receiver). Since the connection will be a "one-way m

Exchange SSL certificates in MQ keystore

username I am trying to establish an SSL connection between two MQ servers. In both certificates, I use self-signed certificates, I created one certificate for QM_A (sender) and another certificate for QM_V (receiver). Since the connection will be a "one-way m

Exchange SSL certificates in MQ keystore

username I am trying to establish an SSL connection between two MQ servers. In both certificates, I use self-signed certificates, I created one certificate for QM_A (sender) and another certificate for QM_V (receiver). Since the connection will be a "one-way m

Java: Load SSL keystore via resource

Gonzo Priest: if I have: System.setProperty("javax.net.ssl.keyStore", '/etc/certificates/fdms/WS1001237590._.1.ks'); System.setProperty("javax.net.ssl.keyStorePassword", 'DV8u4xRVDq'); System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true"); I

Java: Load SSL keystore via resource

Gonzo Priest: if I have: System.setProperty("javax.net.ssl.keyStore", '/etc/certificates/fdms/WS1001237590._.1.ks'); System.setProperty("javax.net.ssl.keyStorePassword", 'DV8u4xRVDq'); System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true"); I

Java: Load SSL keystore via resource

Gonzo Priest: if I have: System.setProperty("javax.net.ssl.keyStore", '/etc/certificates/fdms/WS1001237590._.1.ks'); System.setProperty("javax.net.ssl.keyStorePassword", 'DV8u4xRVDq'); System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true"); I