-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyshark fails to parse the tls.handshake_certificates into actual certificate data.(pyshark无法解析tls.handshake_certificates为实际证书数据) #699
Comments
Here is some usage documentation that I developed and actively maintain for I'm not sure what specific data you're seeking from the First here is an article on Dissecting TLS Using Wireshark. It discusses in detail the handshake process. Here is my code, where I extracted the data related to
Below is part of the extraction related to a certificate. As you see Is this what you were looking for or was it something else?
|
我在使用pyshark解析TLS握手消息时,由于存在多个证书 发现tls.handshake_certificates字段总是返回一个描述性字符串('Certificates (1082 bytes)'),而不是实际的证书数据。我期望能够直接从字段获取多个 DER编码的证书链,以便进一步处理和分析。
When using pyshark to parse TLS handshake messages, especially when there are multiple certificates involved, I've noticed that the tls.handshake_certificates field consistently returns a descriptive string ('Certificates (1082 bytes)'), rather than the actual certificate data. My expectation is to be able to directly obtain the DER-encoded certificate chain from this field, to facilitate further processing and analysis.
This translation maintains the original meaning and intent of your statement in Chinese, describing the issue you're encountering with pyshark and specifying your desired outcome.
if 'handshake_certificates' in tls_field_names: print(str(pkt.tls)) handshake_certificates = pkt.tls.handshake_certificates print(handshake_certificates) x509af_serialnumber = pkt.tls.x509af_serialnumber print(x509af_serialnumber) handshake_certificate = pkt.tls.handshake_certificate print(handshake_certificate)
print
Layer TLS : TLCP Record Layer: Handshake Protocol: Server Hello Content Type: Handshake (22) Version: TLCP (0x0101) Length: 74 Handshake Protocol: Server Hello Handshake Type: Server Hello (2) Length: 70 Version: TLCP (0x0101) Random: 662f0819bc56fd52d5068212b5829d53810ce053ec08ade20b0a2bcbd9cddfeb GMT Unix Time: Apr 29, 2024 10:38:17.000000000 中国标准时间 Random Bytes: bc56fd52d5068212b5829d53810ce053ec08ade20b0a2bcbd9cddfeb Session ID Length: 32 Session ID: 57e73d25feabe79444f7549d3751e9e1ecaa54beccbd1d1b9cc0551c7de34565 Cipher Suite: ECC_SM4_CBC_SM3 (0xe013) Compression Method: null (0) JA3S Fullstring: 257,57363, JA3S: 29679b312f26ae62539fc44a9673b5ca Certificates Length: 840 Certificates (840 bytes) Certificate Length: 417 Certificate: 3082019d30820143a003020102020134300a06082a811ccf55018375304f310b30090603… (id-at-commonName=GateWay,id-at-organizationalUnitName=Venus VPN,id-at-organizationName=Venus,id-at-countryName=CN) signedCertificate version: v3 (2) serialNumber: 0x34 signature (iso.2.156.10197.1.501) Algorithm Id: 1.2.156.10197.1.501 (iso.2.156.10197.1.501) issuer: rdnSequence (0) rdnSequence: 4 items (id-at-commonName=SMxCA for Venus VPN,id-at-organizationalUnitName=Venus VPN,id-at-organizationName=Venus,id-at-countryName=CN) RDNSequence item: 1 item (id-at-countryName=CN) RelativeDistinguishedName item (id-at-countryName=CN) Object Id: 2.5.4.6 (id-at-countryName) CountryName: CN DirectoryString: uTF8String (4) uTF8String: Venus validity notBefore: utcTime (0) utcTime: 2017-06-15 02:46:55 (UTC) notAfter: generalizedTime (1) generalizedTime: Dec 31, 2099 10:46:55.000000000 中国标准时间 subject: rdnSequence (0) rdnSequence: 4 items (id-at-commonName=GateWay,id-at-organizationalUnitName=Venus VPN,id-at-organizationName=Venus,id-at-countryName=CN) subjectPublicKeyInfo algorithm (id-ecPublicKey) ECParameters: namedCurve (1) namedCurve: 1.2.156.10197.1.301 (iso.2.156.10197.1.301) Padding: 0 subjectPublicKey: 04e21b585319df3a09b966310de58c0b4720c573f9b7737baf8b2affab9b9ff5e9ca7627… extensions: 2 items Extension (id-ce-basicConstraints) Extension Id: 2.5.29.19 (id-ce-basicConstraints) BasicConstraintsSyntax [0 length] KeyUsage: c0 1... .... = digitalSignature: True .1.. .... = contentCommitment: True ..0. .... = keyEncipherment: False ...0 .... = dataEncipherment: False .... 0... = keyAgreement: False .... .0.. = keyCertSign: False .... ..0. = cRLSign: False .... ...0 = encipherOnly: False 0... .... = decipherOnly: False algorithmIdentifier (iso.2.156.10197.1.501) encrypted: 30450220376dead8240c99c1da4b41435171dad16625b518813d52e0ea7a2ed11b192458… TLCP Record Layer: Handshake Protocol: Certificate TLCP Record Layer: Handshake Protocol: Server Key Exchange TLCP Record Layer: Handshake Protocol: Server Hello Done Content Type: Handshake (22) Content Type: Handshake (22) Content Type: Handshake (22) Version: TLCP (0x0101) Version: TLCP (0x0101) Version: TLCP (0x0101) Length: 847 Length: 77 Length: 4 Handshake Protocol: Certificate Handshake Protocol: Server Key Exchange Handshake Protocol: Server Hello Done Handshake Type: Certificate (11) Handshake Type: Server Key Exchange (12) Handshake Type: Server Hello Done (14) Length: 843 Length: 73 Length: 0 Certificate Length: 417 Certificate: 3082019d30820143a003020102020133300a06082a811ccf55018375304f310b30090603… (id-at-commonName=GateWay,id-at-organizationalUnitName=Venus VPN,id-at-organizationName=Venus,id-at-countryName=CN) signedCertificate version: v3 (2) serialNumber: 0x33 signature (iso.2.156.10197.1.501) Algorithm Id: 1.2.840.10045.2.1 (id-ecPublicKey) Algorithm Id: 1.2.156.10197.1.501 (iso.2.156.10197.1.501) Algorithm Id: 1.2.156.10197.1.501 (iso.2.156.10197.1.501) Algorithm Id: 1.2.840.10045.2.1 (id-ecPublicKey) Algorithm Id: 1.2.156.10197.1.501 (iso.2.156.10197.1.501) issuer: rdnSequence (0) rdnSequence: 4 items (id-at-commonName=SMxCA for Venus VPN,id-at-organizationalUnitName=Venus VPN,id-at-organizationName=Venus,id-at-countryName=CN) RDNSequence item: 1 item (id-at-organizationName=Venus) RDNSequence item: 1 item (id-at-organizationalUnitName=Venus VPN) RDNSequence item: 1 item (id-at-commonName=SMxCA for Venus VPN) RDNSequence item: 1 item (id-at-countryName=CN) RDNSequence item: 1 item (id-at-organizationName=Venus) RDNSequence item: 1 item (id-at-organizationalUnitName=Venus VPN) RDNSequence item: 1 item (id-at-commonName=GateWay) RDNSequence item: 1 item (id-at-countryName=CN) RDNSequence item: 1 item (id-at-organizationName=Venus) RDNSequence item: 1 item (id-at-organizationalUnitName=Venus VPN) RDNSequence item: 1 item (id-at-commonName=SMxCA for Venus VPN) RDNSequence item: 1 item (id-at-countryName=CN) RDNSequence item: 1 item (id-at-organizationName=Venus) RDNSequence item: 1 item (id-at-organizationalUnitName=Venus VPN) RDNSequence item: 1 item (id-at-commonName=GateWay) RelativeDistinguishedName item (id-at-organizationName=Venus) RelativeDistinguishedName item (id-at-organizationalUnitName=Venus VPN) RelativeDistinguishedName item (id-at-commonName=SMxCA for Venus VPN) RelativeDistinguishedName item (id-at-countryName=CN) RelativeDistinguishedName item (id-at-organizationName=Venus) RelativeDistinguishedName item (id-at-organizationalUnitName=Venus VPN) RelativeDistinguishedName item (id-at-commonName=GateWay) RelativeDistinguishedName item (id-at-countryName=CN) RelativeDistinguishedName item (id-at-organizationName=Venus) RelativeDistinguishedName item (id-at-organizationalUnitName=Venus VPN) RelativeDistinguishedName item (id-at-commonName=SMxCA for Venus VPN) RelativeDistinguishedName item (id-at-countryName=CN) RelativeDistinguishedName item (id-at-organizationName=Venus) RelativeDistinguishedName item (id-at-organizationalUnitName=Venus VPN) RelativeDistinguishedName item (id-at-commonName=GateWay) Object Id: 2.5.4.10 (id-at-organizationName) Object Id: 2.5.4.11 (id-at-organizationalUnitName) Object Id: 2.5.4.3 (id-at-commonName) Object Id: 2.5.4.6 (id-at-countryName) Object Id: 2.5.4.10 (id-at-organizationName) Object Id: 2.5.4.11 (id-at-organizationalUnitName) Object Id: 2.5.4.3 (id-at-commonName) Object Id: 2.5.4.6 (id-at-countryName) Object Id: 2.5.4.10 (id-at-organizationName) Object Id: 2.5.4.11 (id-at-organizationalUnitName) Object Id: 2.5.4.3 (id-at-commonName) Object Id: 2.5.4.6 (id-at-countryName) Object Id: 2.5.4.10 (id-at-organizationName) Object Id: 2.5.4.11 (id-at-organizationalUnitName) Object Id: 2.5.4.3 (id-at-commonName) CountryName: CN CountryName: CN CountryName: CN DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) DirectoryString: uTF8String (4) uTF8String: Venus VPN uTF8String: SMxCA for Venus VPN uTF8String: Venus uTF8String: Venus VPN uTF8String: GateWay uTF8String: Venus uTF8String: Venus VPN uTF8String: SMxCA for Venus VPN uTF8String: Venus uTF8String: Venus VPN uTF8String: GateWay validity notBefore: utcTime (0) utcTime: 2017-06-15 02:46:55 (UTC) notAfter: generalizedTime (1) generalizedTime: Dec 31, 2099 10:46:55.000000000 中国标准时间 subject: rdnSequence (0) rdnSequence: 4 items (id-at-commonName=GateWay,id-at-organizationalUnitName=Venus VPN,id-at-organizationName=Venus,id-at-countryName=CN) subjectPublicKeyInfo algorithm (id-ecPublicKey) ECParameters: namedCurve (1) namedCurve: 1.2.156.10197.1.301 (iso.2.156.10197.1.301) Padding: 6 Padding: 0 Padding: 0 Padding: 3 Padding: 0 subjectPublicKey: 04e21b585319df3a09b966310de58c0b4720c573f9b7737baf8b2affab9b9ff5e9ca7627… extensions: 2 items Extension (id-ce-keyUsage) Extension (id-ce-basicConstraints) Extension (id-ce-keyUsage) Extension Id: 2.5.29.15 (id-ce-keyUsage) Extension Id: 2.5.29.19 (id-ce-basicConstraints) Extension Id: 2.5.29.15 (id-ce-keyUsage) BasicConstraintsSyntax [0 length] KeyUsage: 38 0... .... = digitalSignature: False .0.. .... = contentCommitment: False ..1. .... = keyEncipherment: True ...1 .... = dataEncipherment: True .... 1... = keyAgreement: True .... .0.. = keyCertSign: False .... ..0. = cRLSign: False .... ...0 = encipherOnly: False 0... .... = decipherOnly: False algorithmIdentifier (iso.2.156.10197.1.501) encrypted: 304502201b18de102c857e5e823edfb68140c03dd59c824670b16483d3291b59bb9885cf…
The text was updated successfully, but these errors were encountered: