Skip to content

Commit 3f1e4a0

Browse files
sam-githubtargos
authored andcommitted
tls: expose IETF name for current cipher suite
OpenSSL has its own legacy names, but knowing the IETF name is useful when trouble-shooting, or looking for more information on the cipher. PR-URL: #30637 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Yorkie Liu <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent bc23dfe commit 3f1e4a0

File tree

6 files changed

+25
-2
lines changed

6 files changed

+25
-2
lines changed

doc/api/tls.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -827,16 +827,27 @@ changes:
827827
pr-url: https://github.com/nodejs/node/pull/26625
828828
description: Return the minimum cipher version, instead of a fixed string
829829
(`'TLSv1/SSLv3'`).
830+
- version: REPLACEME
831+
pr-url: https://github.com/nodejs/node/pull/30637
832+
description: Return the IETF cipher name as `standardName`.
830833
-->
831834

832835
* Returns: {Object}
833-
* `name` {string} The name of the cipher suite.
836+
* `name` {string} OpenSSL name for the cipher suite.
837+
* `standardName` {string} IETF name for the cipher suite.
834838
* `version` {string} The minimum TLS protocol version supported by this cipher
835839
suite.
836840

837841
Returns an object containing information on the negotiated cipher suite.
838842

839-
For example: `{ name: 'AES256-SHA', version: 'TLSv1.2' }`.
843+
For example:
844+
```json
845+
{
846+
"name": "AES128-SHA256",
847+
"standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256",
848+
"version": "TLSv1.2"
849+
}
850+
```
840851

841852
See
842853
[SSL_CIPHER_get_name](https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_name.html)

src/env.h

+1
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ constexpr size_t kFsStatsBufferLength =
352352
V(sni_context_string, "sni_context") \
353353
V(source_string, "source") \
354354
V(stack_string, "stack") \
355+
V(standard_name_string, "standardName") \
355356
V(start_time_string, "startTime") \
356357
V(status_string, "status") \
357358
V(stdio_string, "stdio") \

src/node_crypto.cc

+3
Original file line numberDiff line numberDiff line change
@@ -2685,6 +2685,9 @@ void SSLWrap<Base>::GetCipher(const FunctionCallbackInfo<Value>& args) {
26852685
const char* cipher_name = SSL_CIPHER_get_name(c);
26862686
info->Set(context, env->name_string(),
26872687
OneByteString(args.GetIsolate(), cipher_name)).Check();
2688+
const char* cipher_standard_name = SSL_CIPHER_standard_name(c);
2689+
info->Set(context, env->standard_name_string(),
2690+
OneByteString(args.GetIsolate(), cipher_standard_name)).Check();
26882691
const char* cipher_version = SSL_CIPHER_get_version(c);
26892692
info->Set(context, env->version_string(),
26902693
OneByteString(args.GetIsolate(), cipher_version)).Check();

test/parallel/test-tls-getcipher.js

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ server.listen(0, '127.0.0.1', common.mustCall(function() {
5252
}, common.mustCall(function() {
5353
const cipher = this.getCipher();
5454
assert.strictEqual(cipher.name, 'AES128-SHA256');
55+
assert.strictEqual(cipher.standardName, 'TLS_RSA_WITH_AES_128_CBC_SHA256');
5556
assert.strictEqual(cipher.version, 'TLSv1.2');
5657
this.end();
5758
}));
@@ -65,6 +66,8 @@ server.listen(0, '127.0.0.1', common.mustCall(function() {
6566
}, common.mustCall(function() {
6667
const cipher = this.getCipher();
6768
assert.strictEqual(cipher.name, 'ECDHE-RSA-AES128-GCM-SHA256');
69+
assert.strictEqual(cipher.standardName,
70+
'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256');
6871
assert.strictEqual(cipher.version, 'TLSv1.2');
6972
this.end();
7073
}));
@@ -86,6 +89,7 @@ tls.createServer({
8689
}, common.mustCall(() => {
8790
const cipher = client.getCipher();
8891
assert.strictEqual(cipher.name, 'TLS_AES_128_CCM_8_SHA256');
92+
assert.strictEqual(cipher.standardName, cipher.name);
8993
assert.strictEqual(cipher.version, 'TLSv1.3');
9094
client.end();
9195
}));

test/parallel/test-tls-multi-key.js

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ function test(options) {
157157
}, common.mustCall(function() {
158158
assert.deepStrictEqual(ecdsa.getCipher(), {
159159
name: 'ECDHE-ECDSA-AES256-GCM-SHA384',
160+
standardName: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384',
160161
version: 'TLSv1.2'
161162
});
162163
assert.strictEqual(ecdsa.getPeerCertificate().subject.CN, eccCN);
@@ -175,6 +176,7 @@ function test(options) {
175176
}, common.mustCall(function() {
176177
assert.deepStrictEqual(rsa.getCipher(), {
177178
name: 'ECDHE-RSA-AES256-GCM-SHA384',
179+
standardName: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384',
178180
version: 'TLSv1.2'
179181
});
180182
assert.strictEqual(rsa.getPeerCertificate().subject.CN, rsaCN);

test/parallel/test-tls-multi-pfx.js

+2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ const server = tls.createServer(options, function(conn) {
4242
process.on('exit', function() {
4343
assert.deepStrictEqual(ciphers, [{
4444
name: 'ECDHE-ECDSA-AES256-GCM-SHA384',
45+
standardName: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384',
4546
version: 'TLSv1.2'
4647
}, {
4748
name: 'ECDHE-RSA-AES256-GCM-SHA384',
49+
standardName: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384',
4850
version: 'TLSv1.2'
4951
}]);
5052
});

0 commit comments

Comments
 (0)