Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
93c5ad7c
Commit
93c5ad7c
authored
8 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
crypto: make Certificate::isCA() more restrictive
parent
03d52e42
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/crypto.h
+2
-1
2 additions, 1 deletion
include/opendht/crypto.h
src/crypto.cpp
+14
-1
14 additions, 1 deletion
src/crypto.cpp
with
16 additions
and
2 deletions
include/opendht/crypto.h
+
2
−
1
View file @
93c5ad7c
...
@@ -373,7 +373,8 @@ struct OPENDHT_PUBLIC Certificate {
...
@@ -373,7 +373,8 @@ struct OPENDHT_PUBLIC Certificate {
std
::
chrono
::
system_clock
::
time_point
getExpiration
()
const
;
std
::
chrono
::
system_clock
::
time_point
getExpiration
()
const
;
/**
/**
* Returns true if the certificate is marked as a Certificate Authority.
* Returns true if the certificate is marked as a Certificate Authority
* and has necessary key usage flags to sign certificates.
*/
*/
bool
isCA
()
const
;
bool
isCA
()
const
;
...
...
This diff is collapsed.
Click to expand it.
src/crypto.cpp
+
14
−
1
View file @
93c5ad7c
...
@@ -722,7 +722,20 @@ bool
...
@@ -722,7 +722,20 @@ bool
Certificate
::
isCA
()
const
Certificate
::
isCA
()
const
{
{
unsigned
critical
;
unsigned
critical
;
return
gnutls_x509_crt_get_ca_status
(
cert
,
&
critical
)
>
0
;
bool
ca_flag
=
gnutls_x509_crt_get_ca_status
(
cert
,
&
critical
)
>
0
;
if
(
ca_flag
)
{
unsigned
usage
;
auto
ret
=
gnutls_x509_crt_get_key_usage
(
cert
,
&
usage
,
&
critical
);
/* Conforming CAs MUST include this extension in certificates that
contain public keys that are used to validate digital signatures on
other public key certificates or CRLs. */
if
(
ret
<
0
)
return
false
;
if
(
not
critical
)
return
true
;
return
usage
&
GNUTLS_KEY_KEY_CERT_SIGN
;
}
return
false
;
}
}
std
::
string
std
::
string
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment