@@ -1284,12 +1284,6 @@ cmd_cert_help(void)
1284
1284
printf ("cert [--help | display | add <cert_path> | remove <cert_name> | displayown | replaceown (<cert_path.pem> | <cert_path.crt> <key_path.key>)]\n" );
1285
1285
}
1286
1286
1287
- static void
1288
- cmd_crl_help (void )
1289
- {
1290
- printf ("crl [--help | display | add <crl_path> | remove <crl_name>]\n" );
1291
- }
1292
-
1293
1287
static int
1294
1288
cmd_auth (const char * arg , char * * UNUSED (tmp_config_file ))
1295
1289
{
@@ -1911,85 +1905,6 @@ parse_cert(const char *name, const char *path)
1911
1905
fclose (fp );
1912
1906
}
1913
1907
1914
- static void
1915
- parse_crl (const char * name , const char * path )
1916
- {
1917
- int i ;
1918
- BIO * bio_out ;
1919
- FILE * fp ;
1920
- X509_CRL * crl ;
1921
- const ASN1_INTEGER * bs ;
1922
- X509_REVOKED * rev ;
1923
-
1924
- fp = fopen (path , "r" );
1925
- if (fp == NULL ) {
1926
- ERROR ("parse_crl" , "Unable to open \"%s\": %s" , path , strerror (errno ));
1927
- return ;
1928
- }
1929
- crl = PEM_read_X509_CRL (fp , NULL , NULL , NULL );
1930
- if (crl == NULL ) {
1931
- ERROR ("parse_crl" , "Unable to parse certificate: %s" , path );
1932
- fclose (fp );
1933
- return ;
1934
- }
1935
-
1936
- bio_out = BIO_new_fp (stdout , BIO_NOCLOSE );
1937
-
1938
- BIO_printf (bio_out , "-----%s-----\n" , name );
1939
-
1940
- BIO_printf (bio_out , "Issuer: " );
1941
- X509_NAME_print (bio_out , X509_CRL_get_issuer (crl ), 0 );
1942
- BIO_printf (bio_out , "\n" );
1943
-
1944
- BIO_printf (bio_out , "Last update: " );
1945
- #if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
1946
- ASN1_TIME_print (bio_out , X509_CRL_get_lastUpdate (crl ));
1947
- #else
1948
- ASN1_TIME_print (bio_out , X509_CRL_get0_lastUpdate (crl ));
1949
- #endif
1950
- BIO_printf (bio_out , "\n" );
1951
-
1952
- BIO_printf (bio_out , "Next update: " );
1953
- #if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
1954
- ASN1_TIME_print (bio_out , X509_CRL_get_nextUpdate (crl ));
1955
- #else
1956
- ASN1_TIME_print (bio_out , X509_CRL_get0_nextUpdate (crl ));
1957
- #endif
1958
- BIO_printf (bio_out , "\n" );
1959
-
1960
- BIO_printf (bio_out , "REVOKED:\n" );
1961
-
1962
- if ((rev = sk_X509_REVOKED_pop (X509_CRL_get_REVOKED (crl ))) == NULL ) {
1963
- BIO_printf (bio_out , "\tNone\n" );
1964
- }
1965
- while (rev != NULL ) {
1966
- #if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
1967
- bs = rev -> serialNumber ;
1968
- #else
1969
- bs = X509_REVOKED_get0_serialNumber (rev );
1970
- #endif
1971
- BIO_printf (bio_out , "\tSerial no.: " );
1972
- for (i = 0 ; i < bs -> length ; i ++ ) {
1973
- BIO_printf (bio_out , "%02x" , bs -> data [i ]);
1974
- }
1975
-
1976
- BIO_printf (bio_out , " Date: " );
1977
- #if OPENSSL_VERSION_NUMBER < 0x10100000L // < 1.1.0
1978
- ASN1_TIME_print (bio_out , rev -> revocationDate );
1979
- #else
1980
- ASN1_TIME_print (bio_out , X509_REVOKED_get0_revocationDate (rev ));
1981
- #endif
1982
- BIO_printf (bio_out , "\n" );
1983
-
1984
- X509_REVOKED_free (rev );
1985
- rev = sk_X509_REVOKED_pop (X509_CRL_get_REVOKED (crl ));
1986
- }
1987
-
1988
- X509_CRL_free (crl );
1989
- BIO_vfree (bio_out );
1990
- fclose (fp );
1991
- }
1992
-
1993
1908
static int
1994
1909
cmd_cert (const char * arg , char * * UNUSED (tmp_config_file ))
1995
1910
{
@@ -2255,140 +2170,6 @@ cmd_cert(const char *arg, char **UNUSED(tmp_config_file))
2255
2170
return EXIT_FAILURE ;
2256
2171
}
2257
2172
2258
- static int
2259
- cmd_crl (const char * arg , char * * UNUSED (tmp_config_file ))
2260
- {
2261
- int ret ;
2262
- char * args = strdupa (arg );
2263
- char * cmd = NULL , * ptr = NULL , * path , * dest = NULL ;
2264
- char * crl_dir = NULL , * rehash_cmd = NULL ;
2265
- DIR * dir = NULL ;
2266
- struct dirent * d ;
2267
-
2268
- cmd = strtok_r (args , " " , & ptr );
2269
- cmd = strtok_r (NULL , " " , & ptr );
2270
- if (!cmd || !strcmp (cmd , "--help" ) || !strcmp (cmd , "-h" )) {
2271
- cmd_crl_help ();
2272
-
2273
- } else if (!strcmp (cmd , "display" )) {
2274
- int none = 1 ;
2275
- char * name ;
2276
-
2277
- if (!(crl_dir = get_default_CRL_dir (NULL ))) {
2278
- ERROR ("crl display" , "Could not get the default CRL directory" );
2279
- goto error ;
2280
- }
2281
-
2282
- dir = opendir (crl_dir );
2283
- while ((d = readdir (dir ))) {
2284
- if (!strcmp (d -> d_name + strlen (d -> d_name ) - 4 , ".pem" )) {
2285
- none = 0 ;
2286
- name = strdup (d -> d_name );
2287
- name [strlen (name ) - 4 ] = '\0' ;
2288
- if (asprintf (& path , "%s/%s" , crl_dir , d -> d_name ) == -1 ) {
2289
- free (name );
2290
- break ;
2291
- }
2292
- parse_crl (name , path );
2293
- free (name );
2294
- free (path );
2295
- }
2296
- }
2297
- closedir (dir );
2298
- if (none ) {
2299
- printf ("No CRLs found in the default CRL directory.\n" );
2300
- }
2301
-
2302
- } else if (!strcmp (cmd , "add" )) {
2303
- path = strtok_r (NULL , " " , & ptr );
2304
- if (!path || (strlen (path ) < 5 )) {
2305
- ERROR ("crl add" , "Missing or wrong path to the certificate" );
2306
- goto error ;
2307
- }
2308
- if (eaccess (path , R_OK )) {
2309
- ERROR ("crl add" , "Cannot access certificate \"%s\": %s" , path , strerror (errno ));
2310
- goto error ;
2311
- }
2312
-
2313
- crl_dir = get_default_CRL_dir (NULL );
2314
- if (!crl_dir ) {
2315
- ERROR ("crl add" , "Could not get the default CRL directory" );
2316
- goto error ;
2317
- }
2318
-
2319
- if ((asprintf (& dest , "%s/%s" , crl_dir , strrchr (path , '/' ) + 1 ) == -1 ) ||
2320
- (asprintf (& rehash_cmd , "openssl rehash %s &> /dev/null" , crl_dir ) == -1 )) {
2321
- ERROR ("crl add" , "Memory allocation failed" );
2322
- goto error ;
2323
- }
2324
-
2325
- if (strcmp (dest + strlen (dest ) - 4 , ".pem" )) {
2326
- ERROR ("crl add" , "CRLs are expected to be in *.pem format" );
2327
- strcpy (dest + strlen (dest ) - 4 , ".pem" );
2328
- }
2329
-
2330
- if (cp (dest , path )) {
2331
- ERROR ("crl add" , "Could not copy the CRL \"%s\": %s" , path , strerror (errno ));
2332
- goto error ;
2333
- }
2334
-
2335
- if (((ret = system (rehash_cmd )) == -1 ) || WEXITSTATUS (ret )) {
2336
- ERROR ("crl add" , "openssl rehash execution failed" );
2337
- goto error ;
2338
- }
2339
-
2340
- } else if (!strcmp (cmd , "remove" )) {
2341
- path = strtok_r (NULL , " " , & ptr );
2342
- if (!path ) {
2343
- ERROR ("crl remove" , "Missing the certificate name" );
2344
- goto error ;
2345
- }
2346
-
2347
- // delete ".pem" if the user unnecessarily included it
2348
- if ((strlen (path ) > 4 ) && !strcmp (path + strlen (path ) - 4 , ".pem" )) {
2349
- path [strlen (path ) - 4 ] = '\0' ;
2350
- }
2351
-
2352
- crl_dir = get_default_CRL_dir (NULL );
2353
- if (!crl_dir ) {
2354
- ERROR ("crl remove" , "Could not get the default CRL directory" );
2355
- goto error ;
2356
- }
2357
-
2358
- if ((asprintf (& dest , "%s/%s.pem" , crl_dir , path ) == -1 ) ||
2359
- (asprintf (& rehash_cmd , "openssl rehash %s &> /dev/null" , crl_dir ) == -1 )) {
2360
- ERROR ("crl remove" , "Memory allocation failed" );
2361
- goto error ;
2362
- }
2363
-
2364
- if (remove (dest )) {
2365
- ERROR ("crl remove" , "Cannot remove CRL \"%s\": %s (use the name from \"crl display\" output)" ,
2366
- path , strerror (errno ));
2367
- goto error ;
2368
- }
2369
-
2370
- if (((ret = system (rehash_cmd )) == -1 ) || WEXITSTATUS (ret )) {
2371
- ERROR ("crl remove" , "openssl rehash execution failed" );
2372
- goto error ;
2373
- }
2374
-
2375
- } else {
2376
- ERROR ("crl" , "Unknown argument %s" , cmd );
2377
- goto error ;
2378
- }
2379
-
2380
- free (dest );
2381
- free (rehash_cmd );
2382
- free (crl_dir );
2383
- return EXIT_SUCCESS ;
2384
-
2385
- error :
2386
- free (dest );
2387
- free (rehash_cmd );
2388
- free (crl_dir );
2389
- return EXIT_FAILURE ;
2390
- }
2391
-
2392
2173
static int
2393
2174
cmd_connect_listen_tls (struct arglist * cmd , int is_connect )
2394
2175
{
@@ -2397,7 +2178,7 @@ cmd_connect_listen_tls(struct arglist *cmd, int is_connect)
2397
2178
DIR * dir = NULL ;
2398
2179
struct dirent * d ;
2399
2180
int c , n , timeout = 0 , ret = EXIT_FAILURE ;
2400
- char * cert = NULL , * key = NULL , * trusted_dir = NULL , * crl_dir = NULL ;
2181
+ char * cert = NULL , * key = NULL , * trusted_dir = NULL ;
2401
2182
unsigned short port = 0 ;
2402
2183
int option_index = 0 ;
2403
2184
struct option long_options [] = {
@@ -2510,15 +2291,10 @@ cmd_connect_listen_tls(struct arglist *cmd, int is_connect)
2510
2291
goto error_cleanup ;
2511
2292
}
2512
2293
}
2513
- if (!(crl_dir = get_default_CRL_dir (NULL ))) {
2514
- ERROR (func_name , "Could not use the CRL directory." );
2515
- goto error_cleanup ;
2516
- }
2517
2294
2518
2295
if (is_connect ) {
2519
2296
nc_client_tls_set_cert_key_paths (cert , key );
2520
2297
nc_client_tls_set_trusted_ca_paths (trusted_store , trusted_dir );
2521
- nc_client_tls_set_crl_paths (NULL , crl_dir );
2522
2298
2523
2299
/* default port */
2524
2300
if (!port ) {
@@ -2539,7 +2315,6 @@ cmd_connect_listen_tls(struct arglist *cmd, int is_connect)
2539
2315
} else {
2540
2316
nc_client_tls_ch_set_cert_key_paths (cert , key );
2541
2317
nc_client_tls_ch_set_trusted_ca_paths (trusted_store , trusted_dir );
2542
- nc_client_tls_ch_set_crl_paths (NULL , crl_dir );
2543
2318
2544
2319
/* default timeout */
2545
2320
if (!timeout ) {
@@ -2575,7 +2350,6 @@ cmd_connect_listen_tls(struct arglist *cmd, int is_connect)
2575
2350
2576
2351
error_cleanup :
2577
2352
free (trusted_dir );
2578
- free (crl_dir );
2579
2353
free (cert );
2580
2354
free (key );
2581
2355
return ret ;
@@ -6742,9 +6516,6 @@ COMMAND commands[] = {
6742
6516
{"commit" , cmd_commit , cmd_commit_help , "ietf-netconf <commit> operation" },
6743
6517
{"connect" , cmd_connect , cmd_connect_help , "Connect to a NETCONF server" },
6744
6518
{"copy-config" , cmd_copyconfig , cmd_copyconfig_help , "ietf-netconf <copy-config> operation" },
6745
- #ifdef NC_ENABLED_SSH_TLS
6746
- {"crl" , cmd_crl , cmd_crl_help , "Manage Certificate Revocation List directory" },
6747
- #endif
6748
6519
{"delete-config" , cmd_deleteconfig , cmd_deleteconfig_help , "ietf-netconf <delete-config> operation" },
6749
6520
{"delete-sub" , cmd_deletesub , cmd_deletesub_help , "ietf-subscribed-notifications <delete-subscription> operation" },
6750
6521
{"discard-changes" , cmd_discardchanges , cmd_discardchanges_help , "ietf-netconf <discard-changes> operation" },
0 commit comments