Skip to content

Commit e464990

Browse files
tniessendanielleadams
authored andcommitted
crypto: remove checkIP options argument
None of the supported options have any effect on X509_check_ip_asc. Refs: openssl/openssl#17536 PR-URL: #41571 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 7e9ee6e commit e464990

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

doc/api/crypto.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,24 +2509,38 @@ or it might contain wildcards (e.g., `*.example.com`). Because host name
25092509
comparisons are case-insensitive, the returned subject name might also differ
25102510
from the given `name` in capitalization.
25112511

2512-
### `x509.checkIP(ip[, options])`
2512+
If the `'subject'` option is set to `'always'` and if the subject alternative
2513+
name extension either does not exist or does not contain a matching DNS name,
2514+
the certificate subject is considered.
2515+
2516+
If the `'subject'` option is set to `'default'`, the certificate subject is only
2517+
considered if the subject alternative name extension either does not exist or
2518+
does not contain any DNS names. This behavior is consistent with [RFC 2818][]
2519+
("HTTP Over TLS").
2520+
2521+
If the `'subject'` option is set to `'never'`, the certificate subject is never
2522+
considered, even if the certificate contains no subject alternative names.
2523+
2524+
### `x509.checkIP(ip)`
25132525

25142526
<!-- YAML
25152527
added: v15.6.0
2528+
changes:
2529+
- version: REPLACEME
2530+
pr-url: https://github.com/nodejs/node/pull/41571
2531+
description: The `options` argument has been removed since it had no effect.
25162532
-->
25172533

25182534
* `ip` {string}
2519-
* `options` {Object}
2520-
* `subject` {string} `'always'` or `'never'`. **Default:** `'always'`.
2521-
* `wildcards` {boolean} **Default:** `true`.
2522-
* `partialWildcards` {boolean} **Default:** `true`.
2523-
* `multiLabelWildcards` {boolean} **Default:** `false`.
2524-
* `singleLabelSubdomains` {boolean} **Default:** `false`.
25252535
* Returns: {string|undefined} Returns `ip` if the certificate matches,
25262536
`undefined` if it does not.
25272537

25282538
Checks whether the certificate matches the given IP address (IPv4 or IPv6).
25292539

2540+
Only [RFC 5280][] `iPAddress` subject alternative names are considered, and they
2541+
must match the given `ip` address exactly. Other subject alternative names as
2542+
well as the subject field of the certificate are ignored.
2543+
25302544
### `x509.checkIssued(otherCert)`
25312545

25322546
<!-- YAML
@@ -5911,6 +5925,7 @@ See the [list of SSL OP Flags][] for details.
59115925
[RFC 4055]: https://www.rfc-editor.org/rfc/rfc4055.txt
59125926
[RFC 4122]: https://www.rfc-editor.org/rfc/rfc4122.txt
59135927
[RFC 5208]: https://www.rfc-editor.org/rfc/rfc5208.txt
5928+
[RFC 5280]: https://www.rfc-editor.org/rfc/rfc5280.txt
59145929
[Web Crypto API documentation]: webcrypto.md
59155930
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
59165931
[`Buffer`]: buffer.md

lib/internal/crypto/x509.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ class X509Certificate extends JSTransferable {
313313

314314
checkIP(ip, options) {
315315
validateString(ip, 'ip');
316+
// The options argument is currently undocumented since none of the options
317+
// have any effect on the behavior of this function. However, we still parse
318+
// the options argument in case OpenSSL adds flags in the future that do
319+
// affect the behavior of X509_check_ip. This ensures that no invalid values
320+
// are passed as the second argument in the meantime.
316321
return this[kHandle].checkIP(ip, getFlags(options));
317322
}
318323

0 commit comments

Comments
 (0)