MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsMakeServerCredentials

Function cupsMakeServerCredentials

cups/tls-darwin.c:77–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75 */
76
77int /* O - 1 on success, 0 on failure */
78cupsMakeServerCredentials(
79 const char *path, /* I - Keychain path or @code NULL@ for default */
80 const char *common_name, /* I - Common name */
81 int num_alt_names, /* I - Number of subject alternate names */
82 const char **alt_names, /* I - Subject Alternate Names */
83 time_t expiration_date) /* I - Expiration date */
84{
85#if TARGET_OS_OSX
86 int pid, /* Process ID of command */
87 status, /* Status of command */
88 i; /* Looping var */
89 char command[1024], /* Command */
90 *argv[5], /* Command-line arguments */
91 *envp[1000], /* Environment variables */
92 days[32], /* CERTTOOL_EXPIRATION_DAYS env var */
93 keychain[1024], /* Keychain argument */
94 infofile[1024], /* Type-in information for cert */
95 filename[1024]; /* Default keychain path */
96 cups_file_t *fp; /* Seed/info file */
97
98
99 DEBUG_printf(("cupsMakeServerCredentials(path=\"%s\", common_name=\"%s\", num_alt_names=%d, alt_names=%p, expiration_date=%d)", path, common_name, num_alt_names, (void *)alt_names, (int)expiration_date));
100
101 (void)num_alt_names;
102 (void)alt_names;
103
104 if (!path)
105 path = http_cdsa_default_path(filename, sizeof(filename));
106
107 /*
108 * Run the "certtool" command to generate a self-signed certificate...
109 */
110
111 if (!cupsFileFind("certtool", getenv("PATH"), 1, command, sizeof(command)))
112 return (0);
113
114 /*
115 * Create a file with the certificate information fields...
116 *
117 * Note: This assumes that the default questions are asked by the certtool
118 * command...
119 */
120
121 if ((fp = cupsTempFile2(infofile, sizeof(infofile))) == NULL)
122 return (0);
123
124 cupsFilePrintf(fp,
125 "CUPS Self-Signed Certificate\n"
126 /* Enter key and certificate label */
127 "r\n" /* Generate RSA key pair */
128 "2048\n" /* 2048 bit encryption key */
129 "y\n" /* OK (y = yes) */
130 "b\n" /* Usage (b=signing/encryption) */
131 "2\n" /* Sign with SHA256 */
132 "y\n" /* OK (y = yes) */
133 "%s\n" /* Common name */
134 "\n" /* Country (default) */

Callers 1

_httpTLSStartFunction · 0.70

Calls 7

http_cdsa_default_pathFunction · 0.85
cupsFileFindFunction · 0.85
cupsTempFile2Function · 0.85
cupsFilePrintfFunction · 0.85
cupsFileCloseFunction · 0.85
_cupsMutexLockFunction · 0.85
_cupsMutexUnlockFunction · 0.85

Tested by

no test coverage detected