Switching TLS/SSL certificates based on the data in session in a scenario

Hi @Ashwani!

Welcome aboard!

First time I see such a use case. Interesting!

As you mentioned, perUserKeyManagerFactory allow to give a function userId => KeyManagerFactory.

In your case, you need to know a data from the session.
So, you may have to put the association in a common global variable.

    private static Map<Long, String> KIND_BY_USER_ID = new ConcurrentHashMap<>();

In your scenario, after getting data from your CSV, you can put the data from your session into the global association

    ScenarioBuilder users = scenario("Users")
            .feed(myCsv)
            .exec(session -> {
                KIND_BY_USER_ID.put(session.userId(), session.getString("keyStore"));
                return session;
            })
            .exec(search, browse);

So, with a function that fetch the right KeyManagerFactory by your keyStore value, you can add the implementation in the protocol

    HttpProtocolBuilder httpProtocol =
        http.baseUrl("https://computer-database.gatling.io")
// [snip]
           .perUserKeyManagerFactory(userId -> keyManagerFactoryByUserKind.apply(KIND_BY_USER_ID.get(userId)));

What do you think?

Cheers!