-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
V3.0.x cdp #4992
Open
natarajanmm
wants to merge
3
commits into
FreeRADIUS:v3.0.x
Choose a base branch
from
natarajanmm:v3.0.x_cdp
base: v3.0.x
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
V3.0.x cdp #4992
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2880,7 +2880,7 @@ static ocsp_status_t ocsp_check(REQUEST *request, X509_STORE *store, X509 *issue | |
/* | ||
* For creating certificate attributes. | ||
*/ | ||
static char const *cert_attr_names[9][2] = { | ||
static char const *cert_attr_names[10][2] = { | ||
{ "TLS-Client-Cert-Serial", "TLS-Cert-Serial" }, | ||
{ "TLS-Client-Cert-Expiration", "TLS-Cert-Expiration" }, | ||
{ "TLS-Client-Cert-Subject", "TLS-Cert-Subject" }, | ||
|
@@ -2889,7 +2889,8 @@ static char const *cert_attr_names[9][2] = { | |
{ "TLS-Client-Cert-Subject-Alt-Name-Email", "TLS-Cert-Subject-Alt-Name-Email" }, | ||
{ "TLS-Client-Cert-Subject-Alt-Name-Dns", "TLS-Cert-Subject-Alt-Name-Dns" }, | ||
{ "TLS-Client-Cert-Subject-Alt-Name-Upn", "TLS-Cert-Subject-Alt-Name-Upn" }, | ||
{ "TLS-Client-Cert-Valid-Since", "TLS-Cert-Valid-Since" } | ||
{ "TLS-Client-Cert-Valid-Since", "TLS-Cert-Valid-Since" }, | ||
{ "TLS-Client-Cert-CRL-Distribution-Points", "TLS-Cert-CRL-Distribution-Points"} | ||
}; | ||
|
||
#define FR_TLS_SERIAL (0) | ||
|
@@ -2901,11 +2902,39 @@ static char const *cert_attr_names[9][2] = { | |
#define FR_TLS_SAN_DNS (6) | ||
#define FR_TLS_SAN_UPN (7) | ||
#define FR_TLS_VALID_SINCE (8) | ||
#define FR_TLS_CDP (9) | ||
|
||
|
||
static const char *cert_names[2] = { | ||
"client", "server", | ||
}; | ||
|
||
/* | ||
* Extract Certification Distribution point URL from the certificate | ||
*/ | ||
const char *get_dp_url(DIST_POINT *dp) | ||
{ | ||
GENERAL_NAMES *gens; | ||
GENERAL_NAME *gen; | ||
int i, gtype; | ||
ASN1_STRING *uri; | ||
|
||
if (dp == NULL || !dp->distpoint || dp->distpoint->type != 0) { | ||
return NULL; | ||
} | ||
gens = dp->distpoint->name.fullname; | ||
for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) { | ||
gen = sk_GENERAL_NAME_value(gens, i); | ||
uri = GENERAL_NAME_get0_value(gen, >ype); | ||
if (gtype == GEN_URI && ASN1_STRING_length(uri) > 6) { | ||
const char *url_ptr = (const char*) ASN1_STRING_get0_data(uri); | ||
return url_ptr; | ||
} | ||
} | ||
return NULL; | ||
} | ||
|
||
|
||
/* | ||
* Before trusting a certificate, you must make sure that the | ||
* certificate is 'valid'. There are several steps that your | ||
|
@@ -2940,6 +2969,7 @@ int cbtls_verify(int ok, X509_STORE_CTX *ctx) | |
char common_name[1024]; | ||
char cn_str[1024]; | ||
char buf[64]; | ||
char cdp[1024]; | ||
X509 *client_cert; | ||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) | ||
const STACK_OF(X509_EXTENSION) *ext_list; | ||
|
@@ -3079,6 +3109,28 @@ int cbtls_verify(int ok, X509_STORE_CTX *ctx) | |
rdebug_pair(L_DBG_LVL_2, request, vp, NULL); | ||
} | ||
|
||
/* | ||
* Get the Certificate Distribution points | ||
*/ | ||
STACK_OF(DIST_POINT) *crl_dp = X509_get_ext_d2i(client_cert, NID_crl_distribution_points, NULL, NULL); | ||
DIST_POINT *dp; | ||
const char *url_ptr = NULL; | ||
if (crl_dp != NULL) { | ||
for (int i = 0; i < sk_DIST_POINT_num(crl_dp); i++) { | ||
dp = sk_DIST_POINT_value(crl_dp, i); | ||
if (dp != NULL) { | ||
cdp[0] = '\0'; | ||
url_ptr = get_dp_url(dp); | ||
if (url_ptr != NULL) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. continue #2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed both the comments |
||
strncpy(cdp, (char*) url_ptr, (int) strlen(url_ptr)); | ||
cdp[strlen(url_ptr)] = '\0'; | ||
vp = fr_pair_make(talloc_ctx, certs, cert_attr_names[FR_TLS_CDP][lookup], cdp, T_OP_ADD); | ||
rdebug_pair(L_DBG_LVL_2, request, vp, NULL); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/* | ||
* Get the RFC822 Subject Alternative Name | ||
*/ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many nested if's. Consider using
continue
whendp == NULL