Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp30023-2018-project-2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jihai Fan
comp30023-2018-project-2
Commits
c078f1b8
Commit
c078f1b8
authored
7 years ago
by
Jihai Fan
Browse files
Options
Downloads
Patches
Plain Diff
fix warnings and added more comments
parent
9d8663d0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
assignment_2.c
+8
-12
8 additions, 12 deletions
assignment_2.c
certcheck
+0
-0
0 additions, 0 deletions
certcheck
with
8 additions
and
12 deletions
assignment_2.c
+
8
−
12
View file @
c078f1b8
...
@@ -16,11 +16,11 @@ Description: validate of x509 cert against DNS name
...
@@ -16,11 +16,11 @@ Description: validate of x509 cert against DNS name
// get column from csv
// get column from csv
char
*
getfield
(
char
*
line
,
int
num
){
char
*
getfield
(
char
*
line
,
int
num
){
char
*
tok
;
char
*
column
;
char
*
newline
=
strtok
(
line
,
"
\n
"
);
char
*
newline
=
strtok
(
line
,
"
\n
"
);
for
(
tok
=
strtok
(
newline
,
","
);
tok
&&
*
tok
;
tok
=
strtok
(
NULL
,
","
)){
for
(
column
=
strtok
(
newline
,
","
);
column
&&
*
column
;
column
=
strtok
(
NULL
,
","
)){
if
(
!--
num
)
if
(
!--
num
)
return
tok
;
return
column
;
}
}
return
NULL
;
return
NULL
;
}
}
...
@@ -189,18 +189,14 @@ int cmp_san(X509 *cert, char *url){
...
@@ -189,18 +189,14 @@ int cmp_san(X509 *cert, char *url){
}
}
int
validate_url
(
X509
*
cert
,
char
*
url
){
int
validate_url
(
X509
*
cert
,
char
*
url
){
// validation process
int
time_result
=
cmp_time
(
cert
);
int
time_result
=
cmp_time
(
cert
);
int
cn_result
=
cmp_cn
(
cert
,
&
url
);
int
cn_result
=
cmp_cn
(
cert
,
url
);
int
rsa_result
=
cmp_rsa_length
(
cert
);
int
rsa_result
=
cmp_rsa_length
(
cert
);
int
ca_result
=
cmp_ca
(
cert
);
int
ca_result
=
cmp_ca
(
cert
);
int
eku_result
=
cmp_key_usage
(
cert
);
int
eku_result
=
cmp_key_usage
(
cert
);
int
san_result
=
cmp_san
(
cert
,
&
url
);
int
san_result
=
cmp_san
(
cert
,
url
);
// printf("%i\n",time_result);
// printf("%i\n",cn_result);
// printf("%i\n",rsa_result);
// printf("%i\n",ca_result);
// printf("%i\n",eku_result);
// printf("%i\n",san_result);
int
result
;
int
result
;
// only one fo SAN and CN should be
// only one fo SAN and CN should be
if
(
cn_result
==
0
){
if
(
cn_result
==
0
){
...
@@ -214,7 +210,7 @@ int validate_url(X509 *cert, char *url){
...
@@ -214,7 +210,7 @@ int validate_url(X509 *cert, char *url){
return
1
;
return
1
;
}
}
int
read_and_validate
(
const
char
*
test_cert_example
,
const
char
*
url
){
int
read_and_validate
(
const
char
*
test_cert_example
,
char
*
url
){
// const char test_cert_example[] = "cert-file2.pem";
// const char test_cert_example[] = "cert-file2.pem";
BIO
*
certificate_bio
=
NULL
;
BIO
*
certificate_bio
=
NULL
;
X509
*
cert
=
NULL
;
X509
*
cert
=
NULL
;
...
...
This diff is collapsed.
Click to expand it.
certcheck
0 → 100755
+
0
−
0
View file @
c078f1b8
File added
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