예제 #1
0
/* Open the inner, decrypted PKCS7 and try to write CRL.  */ 
void
write_crl(struct scep *s) {
	PKCS7			*p7;
	STACK_OF(X509_CRL)	*crls;
	X509_CRL		*crl;	
	FILE			*fp;

	/* Get CRL */
	p7 = s->reply_p7;
	crls = p7->d.sign->crl;
	
	/* We expect only one CRL: */
	crl = sk_X509_CRL_value(crls, 0);
	if (crl == NULL) {
		fprintf(stderr, "%s: cannot find CRL in reply\n", pname);
		exit (SCEP_PKISTATUS_FILE);
	}

	/* Write PEM-formatted file: */
	if (!(fp = fopen(w_char, "w"))) {
		fprintf(stderr, "%s: cannot open CRL file for writing\n",
				pname);
		exit (SCEP_PKISTATUS_FILE);
	}
	if (v_flag)
		printf("%s: writing CRL\n", pname);
	if (d_flag)
		PEM_write_X509_CRL(stdout, crl);
	if (PEM_write_X509_CRL(fp, crl) != 1) {
		fprintf(stderr, "%s: error while writing CRL "
			"file\n", pname);
		ERR_print_errors_fp(stderr);
		exit (SCEP_PKISTATUS_FILE);
	}
	printf("%s: CRL written as %s\n", pname, w_char);
	(void)fclose(fp);
}
예제 #2
0
파일: pki_crl.cpp 프로젝트: jbfavre/xca
void pki_crl::writeCrl(const QString fname, bool pem)
{
	FILE *fp = fopen(QString2filename(fname), "w");
	if (fp != NULL) {
		if (crl){
			if (pem)
				PEM_write_X509_CRL(fp, crl);
			else
				i2d_X509_CRL_fp(fp, crl);
		}
		fclose(fp);
		pki_openssl_error();
	} else
		fopen_error(fname);
}