File: test.c

package info (click to toggle)
efitools 1.9.2-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 976 kB
  • sloc: ansic: 7,550; makefile: 140; perl: 119; sh: 35
file content (29 lines) | stat: -rw-r--r-- 559 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "typedefs.h"

#include <fcntl.h>

#include <x509.h>

int main(int argc, char *argv[])
{
	void *buf;
	int fd;
	struct stat st;
	char out[512];

	fd = open(argv[1], O_RDONLY);
	if (fd<0) {
		fprintf(stderr, "Failed to open file %s\n", argv[1]);
		perror("");
		exit(1);
	}
	fstat(fd, &st);
	buf = malloc(st.st_size);
	read(fd, buf, st.st_size);
	x509_to_str(buf, st.st_size, X509_OBJ_SUBJECT, out, sizeof(out));
	printf("Subject: %s\n", out);
	x509_to_str(buf, st.st_size, X509_OBJ_ISSUER, out, sizeof(out));
	printf("Issuer: %s\n", out);

	exit(0);
}