1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "apr.h"
#include "apr_errno.h"
#include "apr_pools.h"
#include "apr_strings.h"
#define APR_WANT_MEMFUNC
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "apr_general.h"
#include "apu_config.h"
#include "apu.h"
#include "apr_ssl.h"
#ifdef APU_HAVE_SSL
#include "apr_ssl_private.h"
static int sslInit = 0;
APU_DECLARE(apr_status_t) apr_ssl_init(void)
{
if (!sslInit) {
apr_status_t rv = apu_ssl_init();
if (APR_SUCCESS == rv) {
sslInit = 1;
}
return rv;
}
return APR_SUCCESS;
}
APU_DECLARE(apr_status_t) apr_ssl_factory_create(apr_ssl_factory_t ** fact,
const char *privateKeyFn,
const char *certFn,
const char *digestType,
apr_ssl_factory_type_e why,
apr_pool_t * p)
{
apr_ssl_factory_t *asf;
apr_status_t rv;
if (!p)
return APR_ENOPOOL;
asf = apr_pcalloc(p, sizeof(*asf));
if (!asf)
return ENOMEM;
if (!sslInit) {
rv = apr_ssl_init();
if (APR_SUCCESS != rv) {
return rv;
}
}
*fact = NULL;
asf->pool = p;
asf->purpose = why;
if ((rv = apu_ssl_factory_create(asf, privateKeyFn, certFn,
digestType)) != APR_SUCCESS)
return rv;
/* should we register a cleanup here? */
*fact = asf;
return APR_SUCCESS;
}
APU_DECLARE(const char *) apr_ssl_library_name(void)
{
return APU_SSL_LIBRARY;
}
#else /* ! APU_HAVE_SSL */
APU_DECLARE(apr_status_t) apr_ssl_init(void)
{
return APR_ENOTIMPL;
}
APU_DECLARE(apr_status_t) apr_ssl_factory_create(apr_ssl_factory_t ** fact,
const char *privateKeyFn,
const char *certFn,
const char *digestType,
apr_ssl_factory_type_e why,
apr_pool_t * p)
{
return APR_ENOTIMPL;
}
APU_DECLARE(const char *) apr_ssl_library_name(void)
{
return NULL;
}
#if !APU_HAVE_OPENSSL && !APU_HAVE_WINSOCKSSL
/* default not implemented stubs when neither openssl nor winsock
* are present.
*/
APU_DECLARE(apr_status_t) apr_evp_init(void)
{
return APR_ENOTIMPL;
}
APU_DECLARE(apr_status_t) apr_evp_factory_create(apr_evp_factory_t **newFactory,
const char *privateKeyFn,
const char *certFn,
const char *cipherName,
const char *passphrase,
const char *engine,
const char *digest,
apr_evp_factory_type_e purpose,
apr_pool_t *pool)
{
return APR_ENOTIMPL;
}
APR_DECLARE(apr_status_t) apr_evp_crypt_init(apr_evp_factory_t *f,
apr_evp_crypt_t **e,
apr_evp_crypt_type_e type,
apr_evp_crypt_key_e key,
apr_pool_t *p)
{
return APR_ENOTIMPL;
}
APR_DECLARE(apr_status_t) apr_evp_crypt(apr_evp_crypt_t *evp,
unsigned char **out,
apr_size_t *outlen,
const unsigned char *in,
apr_size_t inlen)
{
return APR_ENOTIMPL;
}
APR_DECLARE(apr_status_t) apr_evp_crypt_finish(apr_evp_crypt_t *evp,
unsigned char *out,
apr_size_t *outlen)
{
return APR_ENOTIMPL;
}
APR_DECLARE(apr_status_t) apr_evp_crypt_cleanup(apr_evp_crypt_t *e)
{
return APR_ENOTIMPL;
}
APR_DECLARE(apr_status_t) apr_evp_factory_cleanup(apr_evp_factory_t *f)
{
return APR_ENOTIMPL;
}
#endif /* !OPENSSL && !WINSOCK */
#endif /* APU_HAVE_SSL */
|