]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/NISCC/TLS_SSL/skipThisNisccCert/skipThisNisccCert.cpp
2 * skipThisNisccCert.cpp - decide whether to use specified NISCC cert
5 #include <Security/cuFileIo.h>
12 #include <sys/param.h>
15 * Currently, SecureTransport does not fragment protocol messages
16 * into record-size chunks. Max record size is 16K so our max cert
17 * size is a little less than that.
19 #define MAX_CERT_SIZE (16 * 1024)
21 static void usage(char **argv
)
23 printf("usage: %s file\n", argv
[0]);
28 * Known file names to NOT parse
30 static const char *skipTheseFiles
[] =
32 /* standard entries */
36 /* the certs we know seem to be fine */
38 /* handled OK by the client now */
44 /* certs with undiagnosed problems */
48 /* returns true if specified fileName is in skipTheseFiles[] */
49 static bool shouldWeSkip(
50 const char *fullPath
) // C string
52 /* strip off leading path components */
53 const char *lastSlash
= NULL
;
55 for(cp
=fullPath
; *cp
!=NULL
; cp
++) {
60 if(lastSlash
== NULL
) {
61 /* no slashes, use full caller-specified filename */
65 /* start one char after last '/' */
68 char fileName
[MAXPATHLEN
];
71 for(const char **stf
=skipTheseFiles
; *stf
!=NULL
; stf
++) {
72 const char *tf
= *stf
;
73 if(!strcmp(fileName
, *stf
)) {
80 int main(int argc
, char **argv
)
86 /* in hard-coded list of files to skip? */
87 const char *filename
= argv
[1];
88 if(shouldWeSkip(filename
)) {
92 /* file size too big? */
94 if(stat(filename
, &sb
)) {
98 if(sb
.st_size
> MAX_CERT_SIZE
) {