Skip to content
Snippets Groups Projects
Commit c078f1b8 authored by Jihai Fan's avatar Jihai Fan
Browse files

fix warnings and added more comments

parent 9d8663d0
Branches
No related tags found
No related merge requests found
...@@ -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;
......
certcheck 0 → 100755
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment