Skip to content

Commit dadc2eb

Browse files
sam-githubrvagg
authored andcommittedNov 28, 2018
doc: describe certificate object properties
PR-URL: #24358 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 50005e7 commit dadc2eb

File tree

1 file changed

+69
-59
lines changed

1 file changed

+69
-59
lines changed
 

‎doc/api/tls.md

+69-59
Original file line numberDiff line numberDiff line change
@@ -638,44 +638,84 @@ added: v0.11.4
638638

639639
* `detailed` {boolean} Include the full certificate chain if `true`, otherwise
640640
include just the peer's certificate.
641-
* Returns: {Object}
641+
* Returns: {Object} A certificate object.
642642

643-
Returns an object representing the peer's certificate. The returned object has
644-
some properties corresponding to the fields of the certificate.
643+
Returns an object representing the peer's certificate. If the peer does not
644+
provide a certificate, an empty object will be returned. If the socket has been
645+
destroyed, `null` will be returned.
645646

646647
If the full certificate chain was requested, each certificate will include an
647648
`issuerCertificate` property containing an object representing its issuer's
648649
certificate.
649650

651+
#### Certificate Object
652+
653+
A certificate object has properties corresponding to the fields of the
654+
certificate.
655+
656+
* `raw` {Buffer} The DER encoded X.509 certificate data.
657+
* `subject` {Object} The certificate subject, described in terms of
658+
Country (`C:`), StateOrProvince (`ST`), Locality (`L`), Organization (`O`),
659+
OrganizationalUnit (`OU`), and CommonName (`CN`). The CommonName is typically
660+
a DNS name with TLS certificates. Example:
661+
`{C: 'UK', ST: 'BC', L: 'Metro', O: 'Node Fans', OU: 'Docs', CN: 'example.com'}`.
662+
* `issuer` {Object} The certificate issuer, described in the same terms as the
663+
`subject`.
664+
* `valid_from` {string} The date-time the certificate is valid from.
665+
* `valid_to` {string} The date-time the certificate is valid to.
666+
* `serialNumber` {string} The certificate serial number, as a hex string.
667+
Example: `'B9B0D332A1AA5635'`.
668+
* `fingerprint` {string} The SHA-1 digest of the DER encoded certificate. It is
669+
returned as a `:` separated hexadecimal string. Example: `'2A:7A:C2:DD:...'`.
670+
* `fingerprint256` {string} The SHA-256 digest of the DER encoded certificate.
671+
It is returned as a `:` separated hexadecimal string. Example:
672+
`'2A:7A:C2:DD:...'`.
673+
* `ext_key_usage` {Array} (Optional) The extended key usage, a set of OIDs.
674+
* `subjectaltname` {Array} (Optional) An array of names for the subject, an
675+
alternative to the `subject` names.
676+
* `infoAccess` {Array} (Optional) An array describing the AuthorityInfoAccess,
677+
used with OCSP.
678+
* `issuerCert` {Object} (Optional) The issuer certificate object. For
679+
self-signed certificates, this may be a circular reference.
680+
681+
The certificate may contain information about the public key, depending on
682+
the key type.
683+
684+
For RSA keys, the following properties may be defined:
685+
* `exponent` {string} The RSA exponent, as a string in hexadecimal number
686+
notation. Example: `'0x010001'`.
687+
* `modulus` {string} The RSA modulus, as a hexadecimal string. Example:
688+
`'B56CE45CB7...'`.
689+
* `pubkey` {Buffer} The public key.
690+
691+
650692
```text
651693
{ subject:
652-
{ C: 'UK',
653-
ST: 'Acknack Ltd',
654-
L: 'Rhys Jones',
655-
O: 'node.js',
656-
OU: 'Test TLS Certificate',
657-
CN: 'localhost' },
694+
{ OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ],
695+
CN: '*.nodejs.org' },
658696
issuer:
659-
{ C: 'UK',
660-
ST: 'Acknack Ltd',
661-
L: 'Rhys Jones',
662-
O: 'node.js',
663-
OU: 'Test TLS Certificate',
664-
CN: 'localhost' },
665-
issuerCertificate:
666-
{ ... another certificate, possibly with an .issuerCertificate ... },
667-
raw: < RAW DER buffer >,
668-
pubkey: < RAW DER buffer >,
669-
valid_from: 'Nov 11 09:52:22 2009 GMT',
670-
valid_to: 'Nov 6 09:52:22 2029 GMT',
671-
fingerprint: '2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:5A:71:38:52:EC:8A:DF',
672-
fingerprint256: '2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:5A:71:38:52:EC:8A:DF:00:11:22:33:44:55:66:77:88:99:AA:BB',
673-
serialNumber: 'B9B0D332A1AA5635' }
697+
{ C: 'GB',
698+
ST: 'Greater Manchester',
699+
L: 'Salford',
700+
O: 'COMODO CA Limited',
701+
CN: 'COMODO RSA Domain Validation Secure Server CA' },
702+
subjectaltname: 'DNS:*.nodejs.org, DNS:nodejs.org',
703+
infoAccess:
704+
{ 'CA Issuers - URI':
705+
[ 'http://crt.comodoca.com/COMODORSADomainValidationSecureServerCA.crt' ],
706+
'OCSP - URI': [ 'http://ocsp.comodoca.com' ] },
707+
modulus: 'B56CE45CB740B09A13F64AC543B712FF9EE8E4C284B542A1708A27E82A8D151CA178153E12E6DDA15BF70FFD96CB8A88618641BDFCCA03527E665B70D779C8A349A6F88FD4EF6557180BD4C98192872BCFE3AF56E863C09DDD8BC1EC58DF9D94F914F0369102B2870BECFA1348A0838C9C49BD1C20124B442477572347047506B1FCD658A80D0C44BCC16BC5C5496CFE6E4A8428EF654CD3D8972BF6E5BFAD59C93006830B5EB1056BBB38B53D1464FA6E02BFDF2FF66CD949486F0775EC43034EC2602AEFBF1703AD221DAA2A88353C3B6A688EFE8387811F645CEED7B3FE46E1F8B9F59FAD028F349B9BC14211D5830994D055EEA3D547911E07A0ADDEB8A82B9188E58720D95CD478EEC9AF1F17BE8141BE80906F1A339445A7EB5B285F68039B0F294598A7D1C0005FC22B5271B0752F58CCDEF8C8FD856FB7AE21C80B8A2CE983AE94046E53EDE4CB89F42502D31B5360771C01C80155918637490550E3F555E2EE75CC8C636DDE3633CFEDD62E91BF0F7688273694EEEBA20C2FC9F14A2A435517BC1D7373922463409AB603295CEB0BB53787A334C9CA3CA8B30005C5A62FC0715083462E00719A8FA3ED0A9828C3871360A73F8B04A4FC1E71302844E9BB9940B77E745C9D91F226D71AFCAD4B113AAF68D92B24DDB4A2136B55A1CD1ADF39605B63CB639038ED0F4C987689866743A68769CC55847E4A06D6E2E3F1',
708+
exponent: '0x10001',
709+
pubkey: <Buffer ... >,
710+
valid_from: 'Aug 14 00:00:00 2017 GMT',
711+
valid_to: 'Nov 20 23:59:59 2019 GMT',
712+
fingerprint: '01:02:59:D9:C3:D2:0D:08:F7:82:4E:44:A4:B4:53:C5:E2:3A:87:4D',
713+
fingerprint256: '69:AE:1A:6A:D4:3D:C6:C1:1B:EA:C6:23:DE:BA:2A:14:62:62:93:5C:7A:EA:06:41:9B:0B:BC:87:CE:48:4E:02',
714+
ext_key_usage: [ '1.3.6.1.5.5.7.3.1', '1.3.6.1.5.5.7.3.2' ],
715+
serialNumber: '66593D57F20CBC573E433381B5FEC280',
716+
raw: <Buffer ... > }
674717
```
675718

676-
If the peer does not provide a certificate, an empty object will be returned.
677-
If the socket has been destroyed, `null` will be returned.
678-
679719
### tlsSocket.getPeerFinished()
680720
<!-- YAML
681721
added: v9.9.0
@@ -830,8 +870,7 @@ added: v0.8.4
830870

831871
* `hostname` {string} The host name or IP address to verify the certificate
832872
against.
833-
* `cert` {Object} An object representing the peer's certificate. The returned
834-
object has some properties corresponding to the fields of the certificate.
873+
* `cert` {Object} A [certificate object][] representing the peer's certificate.
835874
* Returns: {Error|undefined}
836875

837876
Verifies the certificate `cert` is issued to `hostname`.
@@ -847,36 +886,6 @@ the checks done with additional verification.
847886
This function is only called if the certificate passed all other checks, such as
848887
being issued by trusted CA (`options.ca`).
849888

850-
The cert object contains the parsed certificate and will have a structure
851-
similar to:
852-
853-
```text
854-
{ subject:
855-
{ OU: [ 'Domain Control Validated', 'PositiveSSL Wildcard' ],
856-
CN: '*.nodejs.org' },
857-
issuer:
858-
{ C: 'GB',
859-
ST: 'Greater Manchester',
860-
L: 'Salford',
861-
O: 'COMODO CA Limited',
862-
CN: 'COMODO RSA Domain Validation Secure Server CA' },
863-
subjectaltname: 'DNS:*.nodejs.org, DNS:nodejs.org',
864-
infoAccess:
865-
{ 'CA Issuers - URI':
866-
[ 'http://crt.comodoca.com/COMODORSADomainValidationSecureServerCA.crt' ],
867-
'OCSP - URI': [ 'http://ocsp.comodoca.com' ] },
868-
modulus: 'B56CE45CB740B09A13F64AC543B712FF9EE8E4C284B542A1708A27E82A8D151CA178153E12E6DDA15BF70FFD96CB8A88618641BDFCCA03527E665B70D779C8A349A6F88FD4EF6557180BD4C98192872BCFE3AF56E863C09DDD8BC1EC58DF9D94F914F0369102B2870BECFA1348A0838C9C49BD1C20124B442477572347047506B1FCD658A80D0C44BCC16BC5C5496CFE6E4A8428EF654CD3D8972BF6E5BFAD59C93006830B5EB1056BBB38B53D1464FA6E02BFDF2FF66CD949486F0775EC43034EC2602AEFBF1703AD221DAA2A88353C3B6A688EFE8387811F645CEED7B3FE46E1F8B9F59FAD028F349B9BC14211D5830994D055EEA3D547911E07A0ADDEB8A82B9188E58720D95CD478EEC9AF1F17BE8141BE80906F1A339445A7EB5B285F68039B0F294598A7D1C0005FC22B5271B0752F58CCDEF8C8FD856FB7AE21C80B8A2CE983AE94046E53EDE4CB89F42502D31B5360771C01C80155918637490550E3F555E2EE75CC8C636DDE3633CFEDD62E91BF0F7688273694EEEBA20C2FC9F14A2A435517BC1D7373922463409AB603295CEB0BB53787A334C9CA3CA8B30005C5A62FC0715083462E00719A8FA3ED0A9828C3871360A73F8B04A4FC1E71302844E9BB9940B77E745C9D91F226D71AFCAD4B113AAF68D92B24DDB4A2136B55A1CD1ADF39605B63CB639038ED0F4C987689866743A68769CC55847E4A06D6E2E3F1',
869-
exponent: '0x10001',
870-
pubkey: <Buffer ... >,
871-
valid_from: 'Aug 14 00:00:00 2017 GMT',
872-
valid_to: 'Nov 20 23:59:59 2019 GMT',
873-
fingerprint: '01:02:59:D9:C3:D2:0D:08:F7:82:4E:44:A4:B4:53:C5:E2:3A:87:4D',
874-
fingerprint256: '69:AE:1A:6A:D4:3D:C6:C1:1B:EA:C6:23:DE:BA:2A:14:62:62:93:5C:7A:EA:06:41:9B:0B:BC:87:CE:48:4E:02',
875-
ext_key_usage: [ '1.3.6.1.5.5.7.3.1', '1.3.6.1.5.5.7.3.2' ],
876-
serialNumber: '66593D57F20CBC573E433381B5FEC280',
877-
raw: <Buffer ... > }
878-
```
879-
880889
## tls.connect(options[, callback])
881890
<!-- YAML
882891
added: v0.11.3
@@ -1396,5 +1405,6 @@ where `secureSocket` has the same API as `pair.cleartext`.
13961405
[TLS Session Tickets]: https://www.ietf.org/rfc/rfc5077.txt
13971406
[TLS recommendations]: https://wiki.mozilla.org/Security/Server_Side_TLS
13981407
[asn1.js]: https://www.npmjs.com/package/asn1.js
1408+
[certificate object]: #tls_certificate_object
13991409
[modifying the default cipher suite]: #tls_modifying_the_default_tls_cipher_suite
14001410
[specific attacks affecting larger AES key sizes]: https://www.schneier.com/blog/archives/2009/07/another_new_aes.html

0 commit comments

Comments
 (0)
Please sign in to comment.