mirror of https://github.com/ipxe/ipxe.git
[image] Allow "imgtrust" to automatically download cross-signed certificates
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/6/head
parent
89a354d553
commit
071171e807
|
@ -25,6 +25,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
#include <ipxe/uaccess.h>
|
#include <ipxe/uaccess.h>
|
||||||
#include <ipxe/image.h>
|
#include <ipxe/image.h>
|
||||||
#include <ipxe/cms.h>
|
#include <ipxe/cms.h>
|
||||||
|
#include <ipxe/validator.h>
|
||||||
|
#include <ipxe/monojob.h>
|
||||||
#include <usr/imgtrust.h>
|
#include <usr/imgtrust.h>
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
|
@ -46,6 +48,7 @@ int imgverify ( struct image *image, struct image *signature,
|
||||||
size_t len;
|
size_t len;
|
||||||
void *data;
|
void *data;
|
||||||
struct cms_signature *sig;
|
struct cms_signature *sig;
|
||||||
|
struct cms_signer_info *info;
|
||||||
time_t now;
|
time_t now;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -69,6 +72,14 @@ int imgverify ( struct image *image, struct image *signature,
|
||||||
free ( data );
|
free ( data );
|
||||||
data = NULL;
|
data = NULL;
|
||||||
|
|
||||||
|
/* Complete all certificate chains */
|
||||||
|
list_for_each_entry ( info, &sig->info, list ) {
|
||||||
|
if ( ( rc = create_validator ( &monojob, info->chain ) ) != 0 )
|
||||||
|
goto err_create_validator;
|
||||||
|
if ( ( rc = monojob_wait ( NULL ) ) != 0 )
|
||||||
|
goto err_validator_wait;
|
||||||
|
}
|
||||||
|
|
||||||
/* Use signature to verify image */
|
/* Use signature to verify image */
|
||||||
now = time ( NULL );
|
now = time ( NULL );
|
||||||
if ( ( rc = cms_verify ( sig, image->data, image->len,
|
if ( ( rc = cms_verify ( sig, image->data, image->len,
|
||||||
|
@ -86,6 +97,8 @@ int imgverify ( struct image *image, struct image *signature,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_verify:
|
err_verify:
|
||||||
|
err_validator_wait:
|
||||||
|
err_create_validator:
|
||||||
cms_put ( sig );
|
cms_put ( sig );
|
||||||
err_parse:
|
err_parse:
|
||||||
free ( data );
|
free ( data );
|
||||||
|
|
Loading…
Reference in New Issue