]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/vfyCert/vfyCert.c
2 * vfyCert.c - simple "verify one cert with another"
4 #include <security_cdsa_utils/cuFileIo.h>
5 #include <utilLib/common.h>
6 #include <clAppUtils/clutils.h>
10 #include <Security/cssm.h>
12 static void usage(char **argv
)
14 printf("Usage: %s rootCertFile [subjCertFile]\n", argv
[0]);
18 int main(int argc
, char **argv
)
23 CSSM_CL_HANDLE clHand
;
28 if((argc
< 2) || (argc
> 3)) {
31 rtn
= readFile(argv
[1], &rootCert
.Data
, &len
);
33 printf("Error reading %s; %s\n", argv
[1], strerror(rtn
));
36 rootCert
.Length
= len
;
39 subjName
= argv
[1]; // vfy a root cert
44 rtn
= readFile(subjName
, &subjCert
.Data
, (unsigned *)&subjCert
.Length
);
46 printf("Error reading %s; %s\n", argv
[1], strerror(rtn
));
50 if(clHand
== CSSM_INVALID_HANDLE
) {
53 crtn
= CSSM_CL_CertVerify(
55 CSSM_INVALID_HANDLE
, // CCHandle
61 printError("CSSM_CL_CertVerify", crtn
);
64 printf("cert %s verifies OK\n", subjName
);