* No default in the environment, try the user's lpoptions files...
*/
+#if _WIN32
+ snprintf(filename, sizeof(filename), "%s/AppData/Local/cups/lpoptions", cg->home);
+#else
snprintf(filename, sizeof(filename), "%s/.cups/lpoptions", cg->home);
+#endif // _WIN32
dest_name = cups_get_default(filename, defname, sizeof(defname), &instance);
if (cg->home)
{
+#if _WIN32
+ snprintf(filename, sizeof(filename), "%s/AppData/Local/cups/lpoptions", cg->home);
+#else
snprintf(filename, sizeof(filename), "%s/.cups/lpoptions", cg->home);
+#endif // _WIN32
cups_get_dests(filename, dest_name, instance, 0, 1, 1, &dest);
}
* Create ~/.cups subdirectory...
*/
+#if _WIN32
+ snprintf(filename, sizeof(filename), "%s/AppData/Local/cups", cg->home);
+#else
snprintf(filename, sizeof(filename), "%s/.cups", cg->home);
+#endif // _WIN32
if (access(filename, 0))
mkdir(filename, 0700);
+#if _WIN32
+ snprintf(filename, sizeof(filename), "%s/AppData/Local/cups/lpoptions", cg->home);
+#else
snprintf(filename, sizeof(filename), "%s/.cups/lpoptions", cg->home);
+#endif // _WIN32
}
/*
if (cg->home)
{
+#if _WIN32
+ snprintf(filename, sizeof(filename), "%s/AppData/Local/cups/lpoptions", cg->home);
+#else
snprintf(filename, sizeof(filename), "%s/.cups/lpoptions", cg->home);
+#endif // _WIN32
data.num_dests = cups_get_dests(filename, NULL, NULL, 1, user_default != NULL, data.num_dests, &data.dests);
}
}
}
+ fprintf(stderr, "_httpTLSStart: Using hostname '%s'.\n", hostname);
+
return (http_sspi_server(http, hostname));
}
}
}
}
- store = CertOpenStore(CERT_STORE_PROV_SYSTEM, X509_ASN_ENCODING|PKCS_7_ASN_ENCODING, hProv, CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_STORE_NO_CRYPT_RELEASE_FLAG | CERT_STORE_OPEN_EXISTING_FLAG, L"MY");
+ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, X509_ASN_ENCODING|PKCS_7_ASN_ENCODING, hProv, CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_NO_CRYPT_RELEASE_FLAG | CERT_STORE_OPEN_EXISTING_FLAG, L"MY");
if (!store)
{
if (!CryptAcquireContextW(&hProv, (LPWSTR)container, MS_DEF_PROV_W, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET))
{
DEBUG_printf(("5http_sspi_make_credentials: CryptAcquireContext failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError())));
+ fprintf(stderr, "5http_sspi_make_credentials: CryptAcquireContext failed: %s\n", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError()));
ok = FALSE;
goto cleanup;
}
}
}
- store = CertOpenStore(CERT_STORE_PROV_SYSTEM, X509_ASN_ENCODING|PKCS_7_ASN_ENCODING, hProv, CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_STORE_NO_CRYPT_RELEASE_FLAG | CERT_STORE_OPEN_EXISTING_FLAG, L"MY");
+ store = CertOpenStore(CERT_STORE_PROV_SYSTEM, X509_ASN_ENCODING|PKCS_7_ASN_ENCODING, hProv, CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_NO_CRYPT_RELEASE_FLAG | CERT_STORE_OPEN_EXISTING_FLAG, L"MY");
if (!store)
{
DEBUG_printf(("5http_sspi_make_credentials: CertOpenSystemStore failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError())));
+ fprintf(stderr, "5http_sspi_make_credentials: CertOpenSystemStore failed: %s\n", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError()));
ok = FALSE;
goto cleanup;
}
if (!CertStrToNameA(X509_ASN_ENCODING, common_name, CERT_OID_NAME_STR, NULL, NULL, &dwSize, NULL))
{
DEBUG_printf(("5http_sspi_make_credentials: CertStrToName failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError())));
+ fprintf(stderr, "5http_sspi_make_credentials: CertStrToName failed: %s\n", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError()));
ok = FALSE;
goto cleanup;
}
if (!p)
{
DEBUG_printf(("5http_sspi_make_credentials: malloc failed for %d bytes", dwSize));
+ fprintf(stderr, "5http_sspi_make_credentials: malloc failed for %d bytes\n", dwSize);
ok = FALSE;
goto cleanup;
}
if (!CertStrToNameA(X509_ASN_ENCODING, common_name, CERT_OID_NAME_STR, NULL, p, &dwSize, NULL))
{
DEBUG_printf(("5http_sspi_make_credentials: CertStrToName failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError())));
+ fprintf(stderr, "5http_sspi_make_credentials: CertStrToName failed: %s\n", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError()));
ok = FALSE;
goto cleanup;
}
+ sib.cbData = dwSize;
+ sib.pbData = p;
+
/*
* Create a private key and self-signed certificate...
*/
- if (!CryptGenKey(hProv, AT_KEYEXCHANGE, CRYPT_EXPORTABLE, &hKey))
+ if (!CryptGenKey(hProv, AT_KEYEXCHANGE, CRYPT_EXPORTABLE | RSA1024BIT_KEY, &hKey))
{
DEBUG_printf(("5http_sspi_make_credentials: CryptGenKey failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError())));
+ fprintf(stderr, "5http_sspi_make_credentials: CryptGenKey failed: %s\n", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError()));
ok = FALSE;
goto cleanup;
}
if (!createdContext)
{
DEBUG_printf(("5http_sspi_make_credentials: CertCreateSelfSignCertificate failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError())));
+ fprintf(stderr, "5http_sspi_make_credentials: CertCreateSelfSignCertificate failed: %s\n", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError()));
ok = FALSE;
goto cleanup;
}
if (!CertAddCertificateContextToStore(store, createdContext, CERT_STORE_ADD_REPLACE_EXISTING, &storedContext))
{
DEBUG_printf(("5http_sspi_make_credentials: CertAddCertificateContextToStore failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError())));
+ fprintf(stderr, "5http_sspi_make_credentials: CertAddCertificateContextToStore failed: %s\n", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError()));
ok = FALSE;
goto cleanup;
}
if (!CertSetCertificateContextProperty(storedContext, CERT_KEY_PROV_INFO_PROP_ID, 0, &ckp))
{
DEBUG_printf(("5http_sspi_make_credentials: CertSetCertificateContextProperty failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError())));
+ fprintf(stderr, "5http_sspi_make_credentials: CertSetCertificateContextProperty failed: %s\n", http_sspi_strerror(sspi->error, sizeof(sspi->error), GetLastError()));
ok = FALSE;
goto cleanup;
}
if (Status != SEC_E_OK)
{
DEBUG_printf(("5http_sspi_make_credentials: AcquireCredentialsHandle failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), Status)));
+ fprintf(stderr, "5http_sspi_make_credentials: AcquireCredentialsHandle failed: %s\n", http_sspi_strerror(sspi->error, sizeof(sspi->error), Status));
ok = FALSE;
goto cleanup;
}
http_sspi_server(http_t *http, /* I - HTTP connection */
const char *hostname) /* I - Hostname of server */
{
- _http_sspi_t *sspi = http->tls; /* I - SSPI data */
+ _http_sspi_t *sspi = http->tls; /* SSPI data */
char common_name[512]; /* Common name for cert */
DWORD dwSSPIFlags; /* SSL connection attributes we want */
DWORD dwSSPIOutFlags; /* SSL connection attributes we got */
if (!http_sspi_find_credentials(http, L"ServerContainer", common_name))
if (!http_sspi_make_credentials(http->tls, L"ServerContainer", common_name, _HTTP_MODE_SERVER, 10))
{
+ char temp[8192];
+
+ fprintf(stderr, "Unable to create credentials for '%s': %s\n", common_name, http_sspi_strerror(temp, sizeof(temp), GetLastError()));
DEBUG_puts("5http_sspi_server: Unable to get server credentials.");
return (-1);
}