Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
DNS testing tools
Remoh
Commits
b27e06b9
Commit
b27e06b9
authored
Dec 05, 2019
by
Stephane Bortzmeyer
Browse files
[DoT] Displays public key. Addresses #12 #15
parent
db0f03bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
homer.py
View file @
b27e06b9
...
...
@@ -29,6 +29,8 @@ import socket
import
ctypes
import
re
import
os.path
import
hashlib
import
base64
# Values that can be changed from the command line
dot
=
False
# DoH by default
...
...
@@ -172,6 +174,8 @@ class Connection:
if
not
self
.
dot
:
self
.
post
=
post
self
.
head
=
head
if
self
.
dot
:
self
.
hasher
=
hashlib
.
sha256
()
self
.
verbose
=
verbose
self
.
insecure
=
insecure
if
self
.
dot
:
...
...
@@ -198,6 +202,14 @@ class Connection:
# TODO We may here have exceptions such as OpenSSL.SSL.ZeroReturnError
self
.
session
.
do_handshake
()
self
.
cert
=
self
.
session
.
get_peer_certificate
()
# RFC 7858, section 4.2 and appendix A
self
.
publickey
=
self
.
cert
.
get_pubkey
()
if
verbose
:
self
.
hasher
.
update
(
OpenSSL
.
crypto
.
dump_publickey
(
OpenSSL
.
crypto
.
FILETYPE_ASN1
,
self
.
publickey
))
self
.
digest
=
self
.
hasher
.
digest
()
print
(
"Public key is pin-sha256=
\"
%s
\"
"
%
\
base64
.
standard_b64encode
(
self
.
digest
).
decode
())
if
not
insecure
:
valid
=
validate_hostname
(
check
,
self
.
cert
)
if
not
valid
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment