Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
8fbe1cee
Commit
8fbe1cee
authored
Nov 15, 2021
by
Adrian Georgescu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added utility to list TLS CAs
parent
c6155483
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
cas.py
resources/tls/cas.py
+41
-0
No files found.
resources/tls/cas.py
0 → 100755
View file @
8fbe1cee
#!/usr/bin/env python3
from
gnutls.crypto
import
X509Certificate
from
gnutls.errors
import
GNUTLSError
def
trusted_cas
(
content
):
trusted_cas
=
[]
crt
=
''
start
=
False
end
=
False
content
=
content
or
''
content
=
content
.
decode
()
if
isinstance
(
content
,
bytes
)
else
content
for
line
in
content
.
split
(
"
\n
"
):
if
"BEGIN CERT"
in
line
:
start
=
True
crt
=
line
+
"
\n
"
elif
"END CERT"
in
line
:
crt
=
crt
+
line
+
"
\n
"
end
=
True
start
=
False
try
:
trusted_cas
.
append
(
X509Certificate
(
crt
))
except
(
GNUTLSError
,
ValueError
)
as
e
:
continue
elif
start
:
crt
=
crt
+
line
+
"
\n
"
return
trusted_cas
if
__name__
==
'__main__'
:
path
=
"./ca.crt"
content
=
open
(
path
,
'r'
)
.
read
()
cas
=
trusted_cas
(
content
)
i
=
1
for
certificate
in
cas
:
print
(
'
%3
d
%
s'
%
(
i
,
certificate
.
subject
))
i
=
i
+
1
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