Question: I'm having an issue sending our certificate (client) to another server during a web service call.

We're expected to return the certificate with the CN: 

```
b2b-test

```

however whenever we receive the servers certificate and attempt to send our own, we're getting:

```
Unable to find valid certificate path to requested target

```

From my understanding, if I put our certificate b2b-test inside of our keystore jre/lib/security/cacerts, then when receiving the server request, it should send the appropriate certificate.

How does the client know which key from the keystore it should send to the server? Should I be specifying the exact certificate to send during my request, or is it enough for it to be in the keystore?

Currently the server is sending back the certificate

```
b2b-a

```

The certificate chain shows:

```
*** Certificate chain
chain [0] = [
[
  Version: V3
  Subject: CN=b2b-a, OU=Web Technologies

```

The URL for the service is:

```
https://b2b-a/service

```

If I configure it like one way ssl, and put the servers certificate into our cacerts, then it picks up their cert and fails the handshake (I'm assuming because it's expecting our cert and not theirs back due to it being a two way setup).

I'm a little stumped here. Any clarification on what I've said is greatly appreciated.

Answer: 
Assuming you've already got the entered words, you can do something like this:

```
public static void main(String[] args)
{
    String[] enteredWords = {"here", "there", "everywhere"};
    List<String> randomWords = Arrays.asList(enteredWords);
    Collections.shuffle(randomWords);
    System.out.println(randomWords);
}

```
Put the strings in an array and then randomly access the index of the array.