mod_nw_ssl.c revision 3e520e9f095fbbcaa3c216c8ea56e89bd6fd58b4
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele/* Licensed to the Apache Software Foundation (ASF) under one or more
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele * contributor license agreements. See the NOTICE file distributed with
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele * this work for additional information regarding copyright ownership.
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd * The ASF licenses this file to You under the Apache License, Version 2.0
acc36ab93565d2880447d535da6ca6e5feac7a70nd * (the "License"); you may not use this file except in compliance with
acc36ab93565d2880447d535da6ca6e5feac7a70nd * the License. You may obtain a copy of the License at
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * Unless required by applicable law or agreed to in writing, software
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * distributed under the License is distributed on an "AS IS" BASIS,
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
acc36ab93565d2880447d535da6ca6e5feac7a70nd * See the License for the specific language governing permissions and
acc36ab93565d2880447d535da6ca6e5feac7a70nd * limitations under the License.
acc36ab93565d2880447d535da6ca6e5feac7a70nd * mod_tls.c - Apache SSL/TLS module for NetWare by Mike Gardiner.
acc36ab93565d2880447d535da6ca6e5feac7a70nd * This module gives Apache the ability to do SSL/TLS with a minimum amount
acc36ab93565d2880447d535da6ca6e5feac7a70nd * of effort. All of the SSL/TLS logic is already on NetWare versions 5 and
acc36ab93565d2880447d535da6ca6e5feac7a70nd * above and is interfaced through WinSock on NetWare. As you can see in
7db9f691a00ead175b03335457ca296a33ddf31bnd * the code below SSL/TLS sockets can be created with three WinSock calls.
3ca6ee111e6044cb463e6dc45b9adcfa3050ff00rbowen * To load, simply place the module in the modules directory under the main
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele * apache tree. Then add a "SecureListen" with two arguments. The first
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele * argument is an address and/or port. The second argument is the key pair
e50df6c711553f98103f1e0802f7de8c59be7cddslive * name as created in ConsoleOne.
c449ffd09c6af936695e858cff98916215ff76bckess * SecureListen 443 "SSL CertificateIP"
e50df6c711553f98103f1e0802f7de8c59be7cddslive * SecureListen 123.45.67.89:443 mycert
91dbfe27f56a07b53ec19068fdb47581476d5c3brbowen/* The ssl_var_lookup() optional function retrieves SSL environment
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele * variables. */
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele/* An optional function which returns non-zero if the given connection
91dbfe27f56a07b53ec19068fdb47581476d5c3brbowen * is using SSL/TLS. */
252b32956857ad89fc9ee708c4c6eb36097a647cerikabeleAPR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele/* The ssl_proxy_enable() and ssl_engine_disable() optional functions
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele * are used by mod_proxy to enable use of SSL for outgoing
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele * connections. */
252b32956857ad89fc9ee708c4c6eb36097a647cerikabeleAPR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *));
91dbfe27f56a07b53ec19068fdb47581476d5c3brbowenAPR_DECLARE_OPTIONAL_FN(int, ssl_engine_disable, (conn_rec *));
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele#define strcEQn(s1,s2,n) (strncasecmp(s1,s2,n) == 0)
e50df6c711553f98103f1e0802f7de8c59be7cddslive struct sockaddr_in local_addr; /* local IP address and port */
e50df6c711553f98103f1e0802f7de8c59be7cddslivestatic int numcerts = 0;
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele#define get_nwssl_cfg(srv) (NWSSLSrvConfigRec *) ap_get_module_config(srv->module_config, &nwssl_module)
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele certarray = apr_palloc(p, sizeof(unicode_t*)*numcerts);
e50df6c711553f98103f1e0802f7de8c59be7cddslive for (i = 0; i < numcerts; ++i) {
91dbfe27f56a07b53ec19068fdb47581476d5c3brbowen unistr = (unicode_t*)apr_palloc(p, strlen(rootcerts[i])*4);
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele loc2uni (UNI_LOCAL_DEFAULT, unistr, rootcerts[i], 0, 2);
e50df6c711553f98103f1e0802f7de8c59be7cddslive * Parses a host of the form <address>[:port]
e50df6c711553f98103f1e0802f7de8c59be7cddslive * :port is permitted if 'port' is not NULL
a6fc6b44b7f8ad7390864b3555341d3abf867f7endstatic unsigned long parse_addr(const char *w, unsigned short *ports)
e50df6c711553f98103f1e0802f7de8c59be7cddslive unsigned long my_addr;
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele if ((!hep) || (hep->h_addrtype != AF_INET || !hep->h_addr_list[0])) {
e50df6c711553f98103f1e0802f7de8c59be7cddslive /* XXX Should be echoing by h_errno the actual failure, no?
e50df6c711553f98103f1e0802f7de8c59be7cddslive * ap_log_error would be good here. Better yet - APRize.
e50df6c711553f98103f1e0802f7de8c59be7cddslive fprintf(stderr, "Cannot resolve host name %s --- exiting!\n", w);
19e48954d3cfb4f573a99866b0071b6aaa62723ckess fprintf(stderr, "Host %s has multiple addresses ---\n", w);
19e48954d3cfb4f573a99866b0071b6aaa62723ckess fprintf(stderr, "you must choose one explicitly for use as\n");
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele return ((struct in_addr *) (hep->h_addr))->s_addr;
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele if (!memcmp(&sl->local_addr, &lr->local_addr, sizeof(sl->local_addr))) {
252b32956857ad89fc9ee708c4c6eb36097a647cerikabele ((strcmp(sl->addr, "0.0.0.0") == 0) || (strcmp(sl->addr, c->local_ip) == 0))) {
unsigned int optParam;
if (s == INVALID_SOCKET) {
addr);
if (!mutual) {
if (mutual) {
int rcode;
unsigned long ulFlags;
return rcode;
if (numcerts) {
return rcode;
int rcode;
unsigned long ulFlag;
rcode = WSAIoctl(socketHnd, SO_TLS_SET_FLAGS, &ulFlag, sizeof(unsigned long), NULL, 0, NULL, NULL, NULL);
if(rcode)
goto ERR;
rcode = WSAIoctl(socketHnd, SO_TLS_SET_FLAGS, &ulFlag, sizeof(unsigned long),NULL, 0, NULL, NULL, NULL);
if(rcode)
goto ERR;
&sWS2Opts,
sizeof(struct tlsserveropts),
NULL,
NULL,
NULL,
NULL);
goto ERR;
ERR:
return rcode;
const char* mutual)
unsigned short port;
int found_listener = 0;
return err;
if (!port)
if (sa) {
if (found_listener) {
return NULL;
return NULL;
unsigned short port;
return err;
if (!port)
return err;
return APR_SUCCESS;
return NULL;
int found;
found = 0;
if (sa) {
return OK;
return OK;
int found;
if (sa) {
for (secwalk = ap_seclisteners, lastsecwalk = ap_seclisteners; secwalk; secwalk = lastsecwalk->next) {
if (lr) {
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
found = 0;
if (!found) {
return OK;
return new;
return merged;
if (value &&
secsocket_data *csd_data = (secsocket_data*)ap_get_module_config(r->connection->conn_config, &nwssl_module);
return DECLINED;
return DECLINED;
return NULL;
if (isSecure(r))
return DEFAULT_HTTPS_PORT;
const char *result;
if (p == NULL) {
if (r != NULL)
p = r->pool;
else if (c != NULL)
p = c->pool;
if (r != NULL) {
switch (var[0]) {
return (char *)result;
const char *upgrade;
request_rec *r = f->r;
char *key;
int ret;
apr_bucket *b;
if (rv) {
return AP_FILTER_ERROR;
int sockdes;
if (!ret) {
return AP_FILTER_ERROR;
if (isSecureUpgradeable (r)) {
{NULL}