I am trying to test a list of ciphers on a server. I’d like to go through the entire list of ciphers that k6 supports, and try to establish a TLS connection using every cipher. Here’s what I have to accomplish this:
This does not work, since exec.test.options are read-only. Is there any way I can accomplish this in a single script? I realize I could make a bunch of nearly identical scripts with global options set at the top, but I was hoping to accomplish this in a single file.
export default function () {
// array of ciphers to test
let ciphers = [
"TLS_RSA_WITH_RC4_128_SHA",
"TLS_RSA_WITH_3DES_EDE_CBC_SHA",
"TLS_RSA_WITH_AES_128_CBC_SHA",
"TLS_RSA_WITH_AES_256_CBC_SHA",
"TLS_RSA_WITH_AES_128_GCM_SHA256",
"TLS_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
"TLS_ECDHE_RSA_WITH_RC4_128_SHA",
"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
]
// loop through ciphers
for (let i = 0; i < ciphers.length; i++) {
let cipher = ciphers[i];
exec.test.options.tlsCipherSuites = [cipher];
let res = http.get("https://badssl.com");
check(res, {
"is TLSv1.2": (r) => r.tls_version === http.TLS_1_2,
[cipher]: (r) => r.tls_cipher_suite === cipher
});
console.log('Used ' + res.tls_cipher_suite + ' cipher suite');
}
};