Debian Codegraph @

logback-site/src/site/pages/manual/usingSSL.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
6 <title>Chapter 15: Using SSL</title>
7 <link rel="stylesheet" type="text/css" href="../css/common.css" />
8 <link rel="stylesheet" type="text/css" href="../css/screen.css" media="screen" />
9 <link rel="stylesheet" type="text/css" href="../css/_print.css" media="print" />
10 <link rel="stylesheet" type="text/css" href="../css/prettify.css" media="screen" />
11
12 </head>
13 <body onload="prettyPrint(); decorate();">
14 <script type="text/javascript">prefix='../';</script>
15 <script type="text/javascript" src="../js/prettify.js"></script>
16 <script type="text/javascript" src="../templates/header.js"></script>
17 <script type="text/javascript" src="../js/dsl.js"></script>
18 <script type="text/javascript" src="../js/jquery-min.js"></script>
19 <script type="text/javascript" src="../js/decorator.js"></script>
20 <div id="left">
21 <noscript>Please turn on Javascript to view this menu</noscript>
22 <script src="../templates/left.js" type="text/javascript"></script>
23 </div>
24 <div id="right">
25 <script src="menu.js" type="text/javascript"></script>
26 </div>
27 <div id="content">
28
29 <h1>Chapter 15: Using SSL</h1>
30
31
32 <a href="usingSSL_ja.html">&#x548C;&#x8A33; (Japanese translation)</a>
33
34 <div class="quote">
35
36 <p><em>The whole difference between construction and creation is
37 exactly this: that a thing constructed can only be loved after it
38 is constructed; but a thing created is loved before it exists.</em></p>
39 <p>&mdash;CHARLES DICKENS</p>
40 </div>
41
42
43 <script src="../templates/creative.js" type="text/javascript"></script>
44 <!-- script src="../templates/setup.js" type="text/javascript"></script -->
45
46 <p>Logback supports the use of the Secure Sockets Layer
47 (SSL) when delivering log events from a socket-based appender
48 to a remote receiver. When using an SSL-enabled appender and
49 corresponding receiver, serialized logging events are delivered
50 over a secure channel.
51 </p>
52
53 <h2 class="doAnchor">SSL and Component Roles</h2>
54
55 <p>Logback components such as appenders and receivers may act in
56 either the server role or the client role, with respect to network
57 connection initiation. When acting in the server role, a logback
58 component passively listens for connections from remote client
59 components. Conversely, a component acting in the client role
60 initiates a connection to remote server component. For example,
61 an appender acting in the <em>client</em> role connects to a
62 receiver acting in the <em>server</em> role. Or a receiver
63 acting in the <em>client</em> role connects to an appender
64 acting in the <em>server</em> role.</p>
65
66 <p>The roles of the components are generally determined by the
67 component type. For example, an <code>SSLServerSocketAppender</code>
68 is an appender component that acts in the server role, while an
69 <code>SSLSocketAppender</code> is an appender component that acts
70 in the client role. Thus the developer or application administrator
71 can configure Logback components to support the desired direction
72 of network connection initiation.</p>
73
74 <p>The direction of connection initiation is significant in the
75 context of SSL, because in SSL a server component must possess an
76 X.509 credential to identify itself to connecting clients. A
77 client component, when connecting to the server, uses the server's
78 certificate to validate that the server is trusted. The
79 developer or application administrator must be aware of the
80 roles of Logback components, so as to properly configure the
81 server's key store (containing the server's X.509 credential)
82 and the client's trust store (containing self-signed
83 root certificates used when validating server trust).</p>
84
85 <p>When SSL is configured for <em>mutual authentication</em>, then
86 both the server component and the client component must possess
87 valid X.509 credentials whose trust can be asserted by their
88 respective peer. Mutual authentication is configured in the
89 server component, therefore the developer or application
90 administrator must be aware of which components are acting in
91 the server role.</p>
92
93 <p>In this chapter, we use the term <em>server component</em>
94 or simply <em>server</em> to refer to a Logback component such
95 as an appender or receiver that is acting in the server role. We
96 use the term <em>client component</em> or simply <em>client</em>
97 to refer to a component that is acting in the client role.
98
99 <h2 class="doAnchor">SSL and X.509 Certificates</h2>
100
101 <p>In order to use SSL-enabled Logback components, you will need an
102 X.509 credential (a private key, corresponding certificate,
103 and CA certification chain) to identify your components
104 that act as SSL servers. If you wish to use mutual authentication,
105 you will also need credentials for your components that
106 act as SSL clients.
107 </p>
108 <p>While you can use a credential issued by a commercial
109 certification authority (CA), you can also use a certificate issued
110 from your own internal CA or even a self-signed certificate. The
111 following is all that is required:
112 </p>
113 <ol>
114 <li>The server component must be configured
115 with a key store containing the server's private key,
116 corresponding certificate, and CA certification chain
117 (if not using a self-signed certificate).
118 </li>
119 <li>The client component must be configured
120 with a trust store containing trusted root CA
121 certificate(s) or the server's self-signed root certificate.
122 </li>
123 </ol>
124
125 <h2 class="doAnchor">Configuring Logback Components for SSL</h2>
126 <p>The Java Secure Sockets Extension (JSSE) and Java Cryptography
127 Architecture (JCA) which is used to implement Logback's SSL
128 support has many configurable options, and a pluggable provider
129 framework that allows the built-in SSL and cryptographic
130 capabilities of the platform to be replaced or augmented.
131 SSL-enabled Logback components provide the ability to fully specify
132 all of the configurable aspects of the SSL engine and cryptographic
133 providers, to meet your unique security needs.
134 </p>
135
136 <h3>Basic SSL Configuration using JSSE System Properties</h3>
137 <p>Fortunately, nearly all of the configurable SSL properties for
138 SSL-enabled Logback components have reasonable defaults. In
139 most cases all that is needed is the configuration of some JSSE
140 system properties.
141 </p>
142
143 <p>The remainder of this section describes the specific JSSE
144 properties that are needed in most environments. See
145 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#InstallationAndCustomization">
146 Customizing JSSE</a> in the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
147 JSSE Reference Guide</a> for more information on setting JSSE
148 system properties to customize JSSE.
149 </p>
150
151 <p>If you're using any of Logback's SSL-enabled appender or receiver
152 components that act in the server role (e.g.
153 <code>SSLServerSocketReceiver</code>,
154 <code>SSLServerSocketAppender</code>,
155 or <code>SimpleSSLSocketServer</code>) you'll need to configure
156 JSSE system properties that provide the location, type, and
157 password of the key store containing a private key and
158 certificate.
159 </p>
160
161 <h4><a name="basicConfig.keyStore"></a>
162 System Properties for Server Key Store Configuration</h4>
163 <table class="bodyTable striped">
164 <tr>
165 <th>Property Name</th>
166 <th>Description</th>
167 </tr>
168 <tr>
169 <td><code>javax.net.ssl.keyStore</code></td>
170 <td>Specifies a filesystem path to the file containing your
171 server components' private key and certificate.</td>
172 </tr>
173 <tr>
174 <td><code>javax.net.ssl.keyStoreType</code></td>
175 <td>Specifies the key store type. If this property is not
176 specified, the platform's default type (JKS) is assumed.
177 </td>
178 </tr>
179 <tr>
180 <td><code>javax.net.ssl.keyStorePassword</code></td>
181 <td>Specifies the password needed to access the key store.
182 </td>
183 </tr>
184 </table>
185
186 <p>See <a href="#Examples">Examples</a> below for examples of
187 setting these system properties when starting an application
188 that uses Logback's SSL-enabled server components.
189 </p>
190
191 <p>If your server component is using a certificate
192 that was signed by a commercial certification authority (CA),
193 <strong>you probably don't need to provide <em>any</em> SSL
194 configuration in your applications that use SSL-enabled client
195 components</strong>. When using a commercially-signed
196 certificate for your server component, simply setting the
197 system key store properties for JVM that runs the server
198 component is usually all that is needed.
199 </p>
200
201 <p>If you are using either a self-signed server certificate
202 or your server certificate was signed by a
203 certification authority (CA) that is not among those whose root
204 certificates are in the Java platform's default trust store
205 (e.g. when your organization has its own internal certification
206 authority), you will need to configure the JSSE system
207 properties that provide the location, type, and password of the
208 trust store containing your server's certificate or trusted
209 root certificates for the certification authority (CA) that
210 signed your server's certificate. <strong>These properties will
211 need to be set in each application that utilizes an SSL-enabled
212 client component</strong>.
213 </p>
214
215 <h4><a name="basicConfig.trustStore"></a>
216 System Properties for Client Trust Store Configuration</h4>
217 <table class="bodyTable striped">
218 <tr>
219 <th>Property Name</th>
220 <th>Description</th>
221 </tr>
222 <tr>
223 <td><code>javax.net.ssl.trustStore</code></td>
224 <td>Specifies a filesystem path to the file containing your
225 server component's certificate or trusted root
226 certificate(s) for the certification authority (CA) that
227 signed the server certificate.</td>
228 </tr>
229 <tr>
230 <td><code>javax.net.ssl.trustStoreType</code></td>
231 <td>Specifies the trust store type. If this property is not
232 specified, the platform's default type (JKS) is assumed.
233 </td>
234 </tr>
235 <tr>
236 <td><code>javax.net.ssl.trustStorePassword</code></td>
237 <td>Specifies the password needed to access the trust store.
238 </td>
239 </tr>
240 </table>
241
242 <p>See <a href="#Examples">Examples</a> below for examples of
243 setting these system properties when starting an application
244 that utilizes Logback's SSL-enabled client components.
245 </p>
246
247 <h3 class="doAnchor"><a name="SSLConfiguration"></a>
248 Advanced SSL Configuration</h3>
249 <p>In certain situations, the basic SSL configuration using
250 JSSE system properties is not adequate. For example, if you
251 are using the <code>SSLServerSocketReceiver</code> component in a web
252 application, you may wish to use a different credential to
253 identify your logging server for your remote logging clients
254 than the credential that your web server uses to identify
255 itself to web clients. You might wish to use SSL client
256 authentication on your logging server to ensure that only
257 authentic and authorized remote loggers can connect. Or perhaps
258 your organization has strict policies regarding the SSL
259 protocols and cipher suites that may be utilized on the
260 organization's network. For any of these needs, you will need
261 to make use of Logback's advanced configuration options for SSL.
262 </p>
263 <p>When configuring a Logback component that supports SSL, you
264 specify the SSL configuration using the <code>ssl</code>
265 property in the configuration of the component.
266 </p>
267 <p>For example, if you wish to use <code>SSLServerSocketReceiver</code>
268 and configure the key store properties for your logging
269 server's credential, you could use a configuration such as the
270 following.
271 </p>
272
273 <span class="asGroovy" onclick="return asGroovy('logback-ssl-serverKeyStore');">View as .groovy</span>
274 <pre id="logback-ssl-serverKeyStore" class="prettyprint source">&lt;configuration>
275
276 &lt;appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
277 &lt;encoder>
278 &lt;pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n&lt;/pattern>
279 &lt;/encoder>
280 &lt;/appender>
281
282 &lt;root level="debug">
283 &lt;appender-ref ref="CONSOLE" />
284 &lt;/root>
285
286 &lt;receiver class="ch.qos.logback.classic.net.server.SSLServerSocketReceiver">
287 &lt;ssl>
288 &lt;keyStore>
289 &lt;location>classpath:/logging-server-keystore.jks&lt;/location>
290 &lt;password>changeit&lt;/password>
291 &lt;/keyStore>
292 &lt;/ssl>
293 &lt;/receiver>
294
295 &lt;/configuration></pre>
296
297 <p>This configuration specifies the location of the key store
298 as <em>logging-server-keystore.jks</em> at the root of
299 the application's classpath. You could alternatively
300 specify a <code>file:</code> URL to identify the location of
301 the key store.
302 </p>
303 <p>If you wanted to use <code>SSLSocketAppender</code> in your
304 application's Logback configuration, but did not want to change
305 the application's default trust store using the JSSE
306 <code>javax.net.ssl.trustStore</code> property, you could
307 configure the appender as follows.
308 </p>
309
310 <span class="asGroovy" onclick="return asGroovy('logback-ssl-clientTrustStore');">View as .groovy</span>
311 <pre id="logback-ssl-clientTrustStore" class="prettyprint source">&lt;configuration>
312 &lt;appender name="SOCKET" class="ch.qos.logback.classic.net.SSLSocketAppender">
313 &lt;ssl>
314 &lt;trustStore>
315 &lt;location>classpath:/logging-server-truststore.jks&lt;/location>
316 &lt;password>changeit&lt;/password>
317 &lt;/trustStore>
318 &lt;/ssl>
319 &lt;/appender>
320
321 &lt;root level="debug">
322 &lt;appender-ref ref="SOCKET" />
323 &lt;/root>
324
325 &lt;/configuration></pre>
326
327 <p>This configuration specifies the location of the trust store
328 as <em>logging-server-truststore.jks</em> at the root of
329 the application's classpath. You could alternatively
330 specify a <code>file:</code> URL to identify the location of
331 the trust store.
332 </p>
333
334 <h4>SSL Configuration Properties</h4>
335
336 <p>JSSE exposes a large number of configurable options, and
337 Logback's SSL support makes nearly all of them available for
338 you to specify in your SSL-enabled component configuration.
339 When using XML configuration, SSL properties are introduced to
340 these components by nesting an &lt;ssl> element in the
341 component configuration. This configuration element corresponds
342 to the
343 <a href="../xref/ch/qos/logback/core/net/ssl/SSLConfiguration.html">
344 <code>SSLConfiguration</code></a> class.
345 </p>
346
347 <p>When configuring SSL for your components
348 you need only configure those SSL properties for which the
349 defaults are not adequate. Overspecifying the SSL configuration
350 is often the cause of difficult-to-diagnose problems.
351 </p>
352
353 <p>The following table describes the top-level SSL configuration
354 properties. Many of these properties introduce additional
355 subproperties, which are described in tables that follow
356 after the top-level properties are described.
357 </p>
358
359 <table class="bodyTable striped">
360 <tr>
361 <th>Property Name</th>
362 <th>Type</th>
363 <th>Description</th>
364 </tr>
365 <tr>
366 <td><span class="prop" container="ssl">keyManagerFactory</span></td>
367 <td><a href="../xref/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBean.html">
368 <code>KeyManagerFactoryFactoryBean</code></a>
369 </td>
370 <td>Specifies the configuration used to create a
371 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/javax/net/ssl/KeyManagerFactory.html">
372 <code>KeyManagerFactory</code></a>. The Java platform's default
373 factory will be used if this property is not configured. See
374 <a href="#KeyManagerFactoryFactoryBean">Key Manager Factory
375 Configuration</a>
376 below.
377 </td>
378 </tr>
379 <tr>
380 <td><a name="ssl.keyStore"></a><span class="prop" container="ssl">keyStore</span></td>
381 <td><a href="../xref/ch/qos/logback/core/net/ssl/KeyStoreFactoryBean.html">
382 <code>KeyStoreFactoryBean</code></a>
383 </td>
384 <td>
385 <p>Specifies the configuration used to create a
386 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/security/KeyStore.html">
387 <code>KeyStore</code></a>. The KeyStore created by this property
388 should contain a single X.509 credential (consisting of a
389 private key, corresponding certificate, and CA certificate chain).
390 This credential is presented by the local SSL peer to the remote
391 SSL peer.
392 </p>
393 <p>When configuring an SSL client (e.g. <code>SSLSocketAppender</code>),
394 the <span class="prop" container="ssl">keyStore</span> property
395 is needed only if the remote peer is configured to require
396 client authentication.
397 </p>
398 <p>When configuring an SSL server (e.g. <code>SimpleSSLSocketServer</code>)
399 the <span class="prop" container="ssl">keyStore</span> property
400 specifies the key store containing the server's credential. If
401 this property is not configured, the JSSE's
402 <code>javax.net.ssl.keyStore</code> system property must be
403 configured to provide the location of the server's key store.
404 See <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#InstallationAndCustomization">
405 Customizing JSSE</a> in the
406 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
407 JSSE Reference Guide</a> for more information on setting JSSE
408 system properties.
409 </p>
410 <p>See <a href="#KeyStoreFactoryBean">Key Store Configuration</a>
411 below.
412 </p>
413 </td>
414 </tr>
415 <tr>
416 <td><span class="prop" container="ssl">parameters</span></td>
417 <td><a href="../xref/ch/qos/logback/core/net/ssl/SSLParametersConfiguration.html">
418 <code>SSLParametersConfiguration</code></a></td>
419 <td>Specifies various parameters used in SSL session negotiation.
420 See <a href="#SSLParametersConfiguration">SSL Parameters Configuration</a>
421 below.
422 </td>
423 </tr>
424 <tr>
425 <td><span class="prop" container="ssl">protocol</span></td>
426 <td><code>String</code></td>
427 <td>Specifies the SSL protocol that will be used to create an
428 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/javax/net/ssl/SSLContext.html">
429 <code>SSLContext</code></a>.
430 See the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#AppA">
431 Standard Names</a> specification in the
432 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
433 JSSE Reference Guide</a>. The Java platform's default protocol
434 will be used if this property is not configured.
435 </td>
436 </tr>
437 <tr>
438 <td><span class="prop" container="ssl">provider</span></td>
439 <td><code>String</code></td>
440 <td>Specifies the name of the JSSE provider that will be used to
441 create an
442 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/javax/net/ssl/SSLContext.html">
443 <code>SSLContext</code></a>. The Java platform's default JSSE
444 provider will be used if this property is not configured.
445 </td>
446 </tr>
447 <tr>
448 <td><span class="prop" container="ssl">secureRandom</span></td>
449 <td><a href="../xref/ch/qos/logback/core/net/ssl/SecureRandomFactoryBean.html">
450 <code>SecureRandomFactoryBean</code></a>
451 </td>
452 <td>Specifies the configuration used to create a
453 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/security/SecureRandom.html">
454 <code>SecureRandom</code></a> &mdash; a secure random number
455 generator. The Java platform's default generator will be used
456 if this property is not configured. See
457 <a href="#SecureRandomFactoryBean">Secure Random Generator
458 Configuration</a> below.
459 </td>
460 </tr>
461 <tr>
462 <td><span class="prop" container="ssl">trustManagerFactory</span></td>
463 <td><a href="../xref/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBean.html">
464 <code>TrustManagerFactoryFactoryBean</code></a>
465 </td>
466 <td>Specifies the configuration used to create a
467 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/javax/net/ssl/TrustManagerFactory.html">
468 <code>TrustManagerFactory</code></a>. The Java platform's default
469 factory will be used if this property is not configured. See
470 <a href="#TrustManagerFactoryFactoryBean">Trust Manager Factory</a>
471 below.
472 </td>
473 </tr>
474 <tr>
475 <td><a name="ssl.trustStore"></a><span class="prop" container="ssl">trustStore</span></td>
476 <td><a href="../xref/ch/qos/logback/core/net/ssl/KeyStoreFactoryBean.html">
477 <code>KeyStoreFactoryBean</code></a>
478 </td>
479 <td>
480 <p>Specifies the configuration used to create a
481 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/security/KeyStore.html">
482 <code>KeyStore</code></a> used for validating identity of the
483 remote SSL peer. The KeyStore created by this property
484 should contain one or more <em>trust anchors</em> &mdash; self-signed
485 certificates marked as "trusted" in the keystore. Typically,
486 the trust store contains self-signed CA certificates.
487 </p>
488 <p>The trust store specified by this property overrides any trust
489 store specified by the JSSE's <code>javax.net.ssl.trustStore</code>
490 system property and the platform's default trust store.See <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#InstallationAndCustomization">
491 Customizing JSSE</a> in the
492 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
493 JSSE Reference Guide</a> for more information on setting JSSE
494 system properties.
495 </p>
496 </td>
497 </tr>
498 </table>
499
500 <h4 class="doAnchor"><a name="KeyStoreFactoryBean"></a>
501 Key Store Configuration</h4>
502
503 <p>The <a href="../xref/ch/qos/logback/core/net/ssl/KeyStoreFactoryBean.html">
504 <code>KeyStoreFactoryBean</code></a> specifies the
505 configuration needed to create a
506 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/security/KeyStore.html">
507 <code>KeyStore</code></a> containing X.509 credentials. The properties
508 of this factory bean can be used in the
509 <a href="#ssl.keyStore"><span class="prop" container="ssl">keyStore</span></a>
510 and
511 <a href="#ssl.trustStore"><span class="prop" container="ssl">trustStore</span></a>
512 properties of the <a href="#SSLConfiguration">SSL Configuration</a>.
513 </p>
514
515 <table class="bodyTable striped">
516 <tr>
517 <th>Property Name</th>
518 <th>Type</th>
519 <th>Description</th>
520 </tr>
521 <tr>
522 <td><span class="prop" container="keyStore">location</span></td>
523 <td><code>String</code></td>
524 <td>A URL that specifies the location of the key store. Use
525 a <code>file:</code> URL to specify the location of the
526 keystore on a filesystem. Use a <code>classpath:</code>
527 URL to specify a keystore than can be found on the classpath.
528 If the URL doesn't specify a scheme, <code>classpath:</code>
529 is assumed.</td>
530 </tr>
531 <tr>
532 <td><span class="prop" container="keyStore">password</span></td>
533 <td><code>String</code></td>
534 <td>Specifies the password needed to access the key store.</td>
535 </tr>
536 <tr>
537 <td><span class="prop" container="keyStore">provider</span></td>
538 <td><code>String</code></td>
539 <td>Specifies the name of the JCA provider that will be used to
540 create a <code>KeyStore</code>. The Java
541 platform's default key store provider will be used if this
542 property is not configured.
543 </td>
544 </tr>
545 <tr>
546 <td><span class="prop" container="keyStore">type</span></td>
547 <td><code>String</code></td>
548 <td>Specifies the <code>KeyStore</code> type.
549 See the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/CryptoSpec.html#AppA">
550 Standard Names</a> specification in the
551 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/CryptoSpec.html">
552 Java Cryptography Architecture</a> specification. The Java
553 platform's default key store type will be used if this property
554 is not configured.
555 </td>
556 </tr>
557 </table>
558
559 <h4><a name="KeyManagerFactoryFactoryBean"></a>
560 Key Manager Factory Configuration</h4>
561
562 <p>The <a href="../xref/ch/qos/logback/core/net/ssl/KeyManagerFactoryFactoryBean.html">
563 <code>KeyManagerFactoryFactoryBean</code></a> specifies the
564 configuration needed to create a
565 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/javax/net/ssl/KeyManagerFactory.html">
566 <code>KeyManagerFactory</code></a>. Generally, it isn't necessary
567 to explicitly configure the key manager factory, as the platform's
568 default factory is adequate for most needs.
569 </p>
570
571 <table class="bodyTable striped">
572 <tr>
573 <th>Property Name</th>
574 <th>Type</th>
575 <th>Description</th>
576 </tr>
577 <tr>
578 <td><span class="prop" container="keyManagerFactory">algorithm</span></td>
579 <td><code>String</code></td>
580 <td>Specifies the <code>KeyManagerFactory</code> algorithm name.
581 See the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#AppA">
582 Standard Names</a> specification in the
583 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
584 JSSE Reference Guide</a>. The Java platform's default key
585 manager algorithm will be used if this property is not configured.
586 </td>
587 </tr>
588 <tr>
589 <td><span class="prop" container="keyManagerFactory">provider</span></td>
590 <td><code>String</code></td>
591 <td>Specifies the name of the JCA provider that will be used to
592 create a <code>SecureRandom</code> generator. The Java
593 platform's default JSSE provider will be used if this property
594 is not configured.
595 </td>
596 </tr>
597 </table>
598
599 <h4 class="doAnchor"><a name="SecureRandomFactoryBean"></a>
600 Secure Random Generator Configuration</h4>
601
602 <p>The <a href="../xref/ch/qos/logback/core/net/ssl/SecureRandomFactoryBean.html">
603 <code>SecureRandomFactoryBean</code></a> specifies the
604 configuration needed to create a
605 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/security/SecureRandom.html">
606 <code>SecureRandom</code></a> generator. Generally, it isn't necessary
607 to explicitly configure the secure random generator, as the platform's
608 default generator is adequate for most needs.
609 </p>
610
611 <table class="bodyTable striped">
612 <tr>
613 <th>Property Name</th>
614 <th>Type</th>
615 <th>Description</th>
616 </tr>
617 <tr>
618 <td><span class="prop" container="secureRandom">algorithm</span></td>
619 <td><code>String</code></td>
620 <td>Specifies the <code>SecureRandom</code> algorithm name.
621 See the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/CryptoSpec.html#AppA">
622 Standard Names</a> specification in the
623 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/CryptoSpec.html">
624 Java Cryptography Architecture</a> specification. The Java
625 platform's default random number generation algorithm will be used
626 if this property is not configured.
627 </td>
628 </tr>
629 <tr>
630 <td><span class="prop" container="secureRandom">provider</span></td>
631 <td><code>String</code></td>
632 <td>Specifies the name of the JCA provider that will be used to
633 create a <code>SecureRandom</code> generator. The Java
634 platform's default JSSE provider will be used if this property
635 is not configured.
636 </td>
637 </tr>
638 </table>
639
640 <h4><a name="SSLParametersConfiguration"></a>
641 SSL Parameters Configuration</h4>
642
643 <p>The <a href="../xref/ch/qos/logback/core/net/ssl/SSLParametersConfiguration.html">
644 <code>SSLParametersConfiguration</code></a> allows the customization
645 of allowed SSL protocols, cipher suites, and client authentication
646 options.
647 </p>
648
649 <table class="bodyTable striped">
650 <tr>
651 <th>Property Name</th>
652 <th>Type</th>
653 <th>Description</th>
654 </tr>
655 <tr>
656 <td><a name="parameters.excludedCipherSuites"></a>
657 <span class="prop" container="parameters">excludedCipherSuites</span></td>
658 <td><code>String</code></td>
659 <td>
660 <p>Specifies a comma-separated list of SSL cipher suite names or
661 patterns to disable during session negotiation. This property is
662 used to filter the cipher suites supported by the SSL engine,
663 such that any cipher suite matched by this property is disabled.
664 </p>
665 <p>Each field in the comma-separated list specified for this
666 property may be a simple string or a regular expression.
667 </p>
668 <p>See the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#AppA">
669 Standard Names</a> specification in the
670 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
671 JSSE Reference Guide</a> for a list of cipher suite names.
672 </p>
673 </td>
674 </tr>
675 <tr>
676 <td><a name="parameters.includedCipherSuites"></a>
677 <span class="prop" container="parameters">includedCipherSuites</span></td>
678 <td><code>String</code></td>
679 <td>
680 <p>Specifies a comma-separated list of SSL cipher suite names or
681 patterns to enable during session negotiation. This property is
682 used to filter the cipher suites supported by the SSL engine,
683 such that only those cipher suites matched by this property are
684 enabled.
685 </p>
686 <p>Each field in the comma-separated list specified for this
687 property may be a simple string or a regular expression.
688 </p>
689 <p>See the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#AppA">
690 Standard Names</a> specification in the
691 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
692 JSSE Reference Guide</a> for a list of cipher suite names.
693 </p>
694 </td>
695 </tr>
696 <tr>
697 <td><a name="parameters.excludedProtocols"></a>
698 <span class="prop" container="parameters">excludedProtocols</span></td>
699 <td><code>String</code></td>
700 <td>
701 <p>Specifies a comma-separated list of SSL protocol names or
702 patterns to disable during session negotiation. This property is
703 used to filter the protocols supported by the SSL engine,
704 such that any protocol matched by this property is disabled.
705 </p>
706 <p>Each field in the comma-separated list specified for this
707 property may be a simple string or a regular expression.
708 </p>
709 <p>See the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#AppA">
710 Standard Names</a> specification in the
711 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
712 JSSE Reference Guide</a> for a list of protocol names.
713 </p>
714 </td>
715 </tr>
716 <tr>
717 <td><a name="parameters.includedProtocols"></a>
718 <span class="prop" container="parameters">includedProtocols</span></td>
719 <td><code>String</code></td>
720 <td>
721 <p>Specifies a comma-separated list of SSL protocol names or
722 patterns to enable during session negotiation. This property is
723 used to filter the protocols supported by the SSL engine,
724 such that only those protocols matched by this property are
725 enabled.
726 </p>
727 <p>Each field in the comma-separated list specified for this
728 property may be a simple string or a regular expression.
729 </p>
730 <p>See the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#AppA">
731 Standard Names</a> specification in the
732 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
733 JSSE Reference Guide</a> for a list of protocol names.
734 </p>
735 </td>
736 </tr>
737 <tr>
738 <td><a name="parameters.needClientAuth"></a>
739 <span class="prop" container="parameters">needClientAuth</span></td>
740 <td><code>boolean</code></td>
741 <td>Set this property to the value <code>true</code> to
742 configure a server to <em>require</em> a valid client
743 certificate. This property is ignored when configured
744 for a client component such as <code>SSLSocketAppender</code>.
745 </td>
746 </tr>
747 <tr>
748 <td><a name="parameters.wantClientAuth"></a>
749 <span class="prop" container="parameters">wantClientAuth</span></td>
750 <td><code>boolean</code></td>
751 <td>Set this property to the value <code>true</code> to
752 configure the server to <em>request</em> a client
753 certificate. This property is ignored when configured
754 for a client component such as <code>SSLSocketAppender</code>.
755 </td>
756 </tr>
757 </table>
758
759 <h4><a name="TrustManagerFactoryFactoryBean"></a>
760 Trust Manager Factory Configuration</h4>
761
762 <p>The <a href="../xref/ch/qos/logback/core/net/ssl/TrustManagerFactoryFactoryBean.html">
763 <code>TrustManagerFactoryFactoryBean</code></a> specifies the
764 configuration needed to create a
765 <a href="http://docs.oracle.com/javase/1.5.0/docs/api/javax/net/ssl/TrustManagerFactory.html">
766 <code>TrustManagerFactory</code></a>. Generally, it isn't necessary
767 to explicitly configure the trust manager factory, as the platform's
768 default factory is adequate for most needs.
769 </p>
770
771 <table class="bodyTable striped">
772 <tr>
773 <th>Property Name</th>
774 <th>Type</th>
775 <th>Description</th>
776 </tr>
777 <tr>
778 <td><span class="prop" container="trustManagerFactory">algorithm</span></td>
779 <td><code>String</code></td>
780 <td>Specifies the <code>TrustManagerFactory</code> algorithm name.
781 See the <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#AppA">
782 Standard Names</a> specification in the
783 <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html">
784 JSSE Reference Guide</a>. The Java platform's default key
785 manager algorithm will be used if this property is not configured.
786 </td>
787 </tr>
788 <tr>
789 <td><span class="prop" container="trustManagerFactory">provider</span></td>
790 <td><code>String</code></td>
791 <td>Specifies the name of the JCA provider that will be used to
792 create a <code>SecureRandom</code> generator. The Java
793 platform's default JSSE provider will be used if this property
794 is not configured.
795 </td>
796 </tr>
797 </table>
798
799 <h2 class="doAnchor"><a name="Examples"></a>Examples</h2>
800
801 <h3>Using JSSE System Properties</h3>
802 <p>JSSE system properties can be used to specify the location and
803 password for a key store containing your server's X.509 credential,
804 or to specify the location and password for a trust store
805 containing self-signed root CA certificates used by your client
806 components to validate server trust.</p>
807
808 <h4>Specifying the Server's Key Store</h4>
809 <p>When running a server component, you need to specify the location
810 and password for the key store containing the server's credential.
811 One way to do this is using JSSE system properties. The following
812 example shows a command line that could be used to start the
813 <code>SimpleSSLSocketServer</code> that is shipped with Logback.</p>
814
815 <p class="source">java -DkeyStore=/etc/logback-server-keystore.jks \
816 -DkeyStorePassword=changeit -DkeyStoreType=JKS \
817 ch.qos.logback.net.SimpleSSLSocketServer 6000 /etc/logback-server-config.xml</p>
818
819 <p>Note that when using the JSSE <em>keyStore</em> system property,
820 a path to the key store is specified. When specifying the location
821 in <em>logback.xml</em>, a URL for the key store is specified.</p>
822
823 <p>While this example starts the standalone server application
824 provided with Logback, the same system properties could be specified
825 to start any application that uses an SSL-enabled Logback server
826 component.
827
828 <h4>Specifying the Client's Trust Store</h4>
829
830 <p>When using a client component, you need to specify the location
831 and password for a trust store containing root CA certificates used
832 for validating server trust. One way to do this is using JSSE
833 system properties. The following example shows a command line
834 that could be used to start an application named
835 <code>com.example.MyLoggingApplication</code> that uses one or
836 more of Logback's SSL-enabled client components.</p>
837
838 <p class="source">java -DtrustStore=/etc/logback-client-truststore.jks \
839 -DtrustStorePassword=changeit -DtrustStoreType=JKS \
840 com.example.MyLoggingApplication</p>
841
842 <p>Note that when using the JSSE <em>trustStore</em> system property,
843 a path to the key store is specified. When specifying the location
844 in <em>logback.xml</em>, a URL for the trust store is specified.</p>
845
846 <h3>Creating and Using a Self-Signed Server Component Credential</h3>
847 <p>To generate a self-signed certificate, you can use the <em>keytool</em>
848 utility that is shipped with the Java Runtime Environment (JRE).
849 The instructions below walk through the process of creating a
850 self-signed X.509 credential in a key store for your server
851 component and creating a trust store for use with your client
852 components.
853 </p>
854
855 <h4>Creating the server component credential:</h4>
856 <p>The following command will generate the self-signed client
857 credential in a file named <em>server.keystore</em>.</p>
858 <pre class="source">keytool -genkey -alias server -dname &quot;CN=my-logging-server&quot; \
859 -keyalg RSA -validity 365 -keystore server.keystore
860 Enter keystore password: &lt;Enter password of your choosing>
861 Re-enter new password: &lt;Re-enter same password>
862 Enter key password for &lt;my-logging-server>
863 (RETURN if same as keystore password): &lt;Press RETURN>
864 </pre>
865
866 <p>The name <em>my-logging-server</em> used in the <em>dname</em>
867 may be any valid name of your choosing. You may wish to use the
868 fully-qualified domain name of the server host. The
869 <em>validity</em> argument specifies the number of calendar days
870 from the present date until the credential expires.</p>
871
872 <p>In production settings, it is especially important to choose a
873 strong password for the key store containing your server credential.
874 This password protects the server's private key, preventing it
875 from being used by an authorized party. Make note of the
876 password, because you will need it in subsequent steps and when
877 configuring your server.
878 </p>
879
880 <h4>Creating a trust store for client components:</h4>
881 <p>For use in the configuration of your client components, the
882 server's certificate needs to be exported from the key store
883 created in the previous step, and imported into a trust store. The
884 following commands will export the certificate and import it into
885 a trust store named <em>server.truststore</em>.</p>
886
887 <pre class="source">keytool -export -rfc -alias server -keystore server.keystore \
888 -file server.crt
889 Enter keystore password: &lt;Enter password you chose for in previous step>
890
891 keytool -import -alias server -file server.crt -keystore server.truststore
892 Enter keystore password: &lt;Enter password of your choosing>
893 Re-enter new password: &lt;Re-enter same password>
894 Owner: CN=my-logging-server
895 Issuer: CN=my-logging-server
896 Serial number: 6e7eea40
897 Valid from: Sun Mar 31 07:57:29 EDT 2013 until: Mon Mar 31 07:57:29 EDT 2014
898
899 ...
900
901 Trust this certificate? [no]: &lt;Enter "yes">
902 </pre>
903
904 <p>The first command exports the server's certificate (but not the
905 server's private key) from the key store and into a file named
906 <em>server.crt</em>. The second step creates a new trust store
907 named <em>server.truststore</em> containing the server certificate.
908 </p>
909
910 <p>In production settings, it is especially important to choose a
911 strong password for the trust store that is different from the
912 password you chose of the server key store. Make note of this
913 password, because you will need it when configuring your appender
914 clients.
915 </p>
916
917 <h4>Configuring the server component:</h4>
918 <p>You will need to copy the <em>server.keystore</em> file into your
919 server application's configuration. The key store can be placed
920 with your application's classpath resources, or it may simply be
921 placed somewhere on the server host's filesystem. When specifying
922 the location of the key store in the configuration, you will use
923 either a <code>classpath:</code> URL or <code>file:</code> URL, as
924 appropriate. A example server configuration follows:</p>
925
926 <p class="example">Example: Server Component Configuration</p>
927 <pre class="prettyprint source">&lt;configuration debug="true">
928 &lt;appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
929 &lt;encoder>
930 &lt;pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n&lt;/pattern>
931 &lt;/encoder>
932 &lt;/appender>
933
934 &lt;root level="DEBUG">
935 &lt;appender-ref ref="CONSOLE" />
936 &lt;/root>
937
938 &lt;server class="ch.qos.logback.classic.net.server.SSLServerSocketReceiver">
939 &lt;ssl>
940 &lt;keyStore>
941 &lt;location>classpath:server.keystore&lt;/location>
942 &lt;password>${server.keystore.password}&lt;/password>
943 &lt;/keyStore>
944 &lt;/ssl>
945 &lt;/server>
946 &lt;/configuration></pre>
947
948 <p>This example assumes that the key store is located at the root
949 of the application's classpath.</p>
950
951 <p>Note that this configuration specifies the key store password
952 using the <em>server.keystore.password</em> substitution variable.
953 This approach would allow you to avoid storing the password in
954 any configuration file. For example, your application could
955 prompt for this password on the console at startup, and then
956 set the <em>server.keystore.password</em> as a system property
957 using the entered password before configuring the logging system.
958 </p>
959
960 <h4>Configuring client components:</h4>
961 <p>You will need to copy the <em>server.truststore</em> file into
962 the application configuration of each application that uses an
963 SSL-enabled component acting in the client mode. The trust store
964 can be placed with your application's classpath resources, or it
965 may simply be placed somewhere on the filesystem. When specifying
966 the location of the trust store in the configuration, you will use
967 either a <code>classpath:</code> URL or <code>file:</code> URL, as
968 appropriate. A example appender client configuration follows:</p>
969
970 <p class="example">Example: Appender Client Configuration</p>
971
972 <pre class="prettyprint source">&lt;configuration debug="true">
973 &lt;appender name="SOCKET" class="ch.qos.logback.classic.net.SSLSocketAppender">
974 &lt;remoteHost>${host}&lt;/remoteHost>
975 &lt;ssl>
976 &lt;trustStore>
977 &lt;location>classpath:server.truststore&lt;/location>
978 &lt;password>${server.truststore.password}&lt;/password>
979 &lt;/trustStore>
980 &lt;/ssl>
981 &lt;/appender>
982
983 &lt;root level="DEBUG">
984 &lt;appender-ref ref="SOCKET" />
985 &lt;/root>
986 &lt;/configuration></pre>
987
988 <p>This example assumes that the trust store is located at the root
989 of the application's classpath.</p>
990
991 <p>Note that this configuration specifies the trust store password
992 using the <em>server.truststore.password</em> substitution variable.
993 This approach would allow you to avoid storing the password in
994 any configuration file. For example, your application could
995 prompt for this password on the console at startup, and then
996 set the <em>server.truststore.password</em> as a system property
997 using the entered password before configuring the logging system.
998 </p>
999
1000 <h2>Auditing the SSL Configuration</h2>
1001 <p>In settings where secure communications are required, it is often
1002 necessary to audit the configuration of components that use SSL to
1003 validate conformance with local security policies. The SSL
1004 support in Logback addresses this need by providing detailed
1005 logging of SSL configuration when Logback is initialized. You can
1006 enable audit logging using the <code>debug</code> property in the
1007 configuration:</p>
1008
1009 <pre class="prettyprint source">&lt;configuration debug="true">
1010
1011 ...
1012
1013 &lt;/configuration></pre>
1014
1015 <p>With the debug property enabled, all of the relevant aspects of
1016 the resulting SSL configuration will be logged when the logging
1017 system is initialized. A representative example of the information
1018 logged for SSL follows.</p>
1019
1020 <p class="example">Example: SSL Configuration Audit Logging</p>
1021
1022 <pre>06:46:31,941 |-INFO in SSLServerSocketReceiver@4ef18d37 - SSL protocol 'SSL' provider 'SunJSSE version 1.6'
1023 06:46:31,967 |-INFO in SSLServerSocketReceiver@4ef18d37 - key store of type 'JKS' provider 'SUN version 1.6': file:src/main/java/chapters/appenders/socket/ssl/keystore.jks
1024 06:46:31,967 |-INFO in SSLServerSocketReceiver@4ef18d37 - key manager algorithm 'SunX509' provider 'SunJSSE version 1.6'
1025 06:46:31,973 |-INFO in SSLServerSocketReceiver@4ef18d37 - secure random algorithm 'SHA1PRNG' provider 'SUN version 1.6'
1026 06:46:32,755 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled protocol: SSLv2Hello
1027 06:46:32,755 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled protocol: SSLv3
1028 06:46:32,755 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled protocol: TLSv1
1029 06:46:32,756 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled cipher suite: SSL_RSA_WITH_RC4_128_MD5
1030 06:46:32,756 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled cipher suite: SSL_RSA_WITH_RC4_128_SHA
1031 06:46:32,756 |-INFO in SSLParametersConfiguration@4a6f19d5 - enabled cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA
1032 </pre>
1033
1034 <p>The output shown here has been truncated for brevity's sake,
1035 but would typically include the complete list of protocols,
1036 providers, algorithms, and cipher suites, as well as the location
1037 of key store and trust store resources utilized in the configuration.
1038 </p>
1039
1040 <p>While none of this audit logging is particularly sensitive,
1041 best practices for security would suggest that this logging should
1042 not remain enabled in production settings after the configuration
1043 has been validated. Audit logging is disabled when the
1044 <code>debug</code> property is removed or set to <code>false</code>.
1045 </p>
1046
1047 <h2>Resolving SSL Exceptions</h2>
1048 <p>When SSL is misconfigured, it generally results in the client
1049 and server components being unable to negotiate an agreeable
1050 session. This problem usually manifests itself as exceptions
1051 being thrown by both parties when the client attempts to connect
1052 to the server.
1053 </p>
1054 <p>The content of the exception messages varies depending on whether
1055 you are looking at the client's log or the server's log. This
1056 is mostly due to inherent protocol limitations in error reporting
1057 during session negotiation. As a consequence of this fact,
1058 in order to troubleshoot session negotiation problems, you will
1059 usually want to look at the logs of both the client and the
1060 server.
1061 </p>
1062
1063 <h3>Server's Certificate is Not Available</h3>
1064 <p>When starting the server component, you
1065 see the following exception in the log:</p>
1066
1067 <p><em>javax.net.ssl.SSLException: No available certificate or
1068 key corresponds to the SSL cipher suites which are enabled</em>
1069 </p>
1070
1071 <p>In most cases this means that you have not configured
1072 the location of the key store containing the server's private
1073 key and corresponding certificate.
1074 </p>
1075
1076 <h4>Solution</h4>
1077 <p>Using either the
1078 <a href="#basicConfig.keyStore">Key Store system
1079 properties</a> or the <a href="#ssl.keyStore">
1080 <span class="prop">keyStore</span></a> property of the
1081 server component's <span class="prop">ssl</span> property,
1082 you must specify the location and password for the key store
1083 containing the server's private key and certificate.
1084 </p>
1085
1086 <h3>Client Does Not Trust the Server</h3>
1087 <p>When the client attempts to connect to the server, you see the
1088 following exception in the log:</p>
1089
1090 <p><em>javax.net.ssl.SSLHandshakeException:
1091 sun.security.validator.ValidatorException:
1092 PKIX path building failed</em>
1093 </p>
1094 <p>This problem is the result of the server presenting a certificate
1095 the client does not trust. The most common cause is that you
1096 are using a self-signed server certificate (or a server
1097 certificate that was signed by your organization's internal
1098 certification authority) and you have not configured the client
1099 so that it references a trust store containing the server's
1100 self-signed certificate (or the trusted root certificate(s) for
1101 the CA that signed your server certificate).
1102 </p>
1103 <p>This problem can also occur if your server certificate has
1104 expired or has been revoked. If you have access to the server
1105 log you will likely see the following exception logged
1106 each time the client attempts to connect:
1107 </p>
1108
1109 <p><em>javax.net.ssl.SSLHandshakeException: Received fatal alert: ...</em>
1110 </p>
1111
1112 <p>The remainder of the exception message will usually provide a
1113 code that indicates why the client rejected the server's
1114 certificate.
1115 </p>
1116 <table class="bodyTable striped">
1117 <tr>
1118 <th>Code</th>
1119 <th>Description</th>
1120 </tr>
1121 <tr>
1122 <td><code>certificate_unknown</code></td>
1123 <td>Usually indicates that the client's trust store has not
1124 been properly configured.
1125 </td>
1126 </tr>
1127 <tr>
1128 <td><code>certificate_expired</code></td>
1129 <td>Indicates that the server's certificate has expired and
1130 needs to be replaced.
1131 </td>
1132 </tr>
1133 <tr>
1134 <td><code>certificate_revoked</code></td>
1135 <td>Indicates that the issuing certification authority (CA)
1136 has revoked the server's certificate and the certificate
1137 needs to be replaced.
1138 </td>
1139 </tr>
1140 </table>
1141
1142 <h4>Solutions</h4>
1143 <p>If the server's log message is reporting <code>certificate_unknown</code>
1144 then using either the <a href="#basicConfig.trustStore">Trust Store system
1145 properties</a> or the <a href="#ssl.trustStore">
1146 <span class="prop">trustStore</span></a> property of the
1147 appender component's <span class="prop">ssl</span> property,
1148 you must specify the location and password for the trust
1149 store containing the server's self-signed certificate or
1150 the issuing certificate authority's root certificate.
1151 </p>
1152
1153 <p>If the server's log message is reporting
1154 <code>certificate_expired</code> or <code>certificate_revoked</code>
1155 the server needs a new certificate. The new certificate
1156 and associated private key needs to be placed in the key store
1157 specified in the server's configuration. And, if using
1158 a self-signed server certificate, the server's certificate also
1159 needs to be placed in the trust store specified in the appender
1160 client's configuration.
1161 </p>
1162
1163 <h3>Server Does Not Trust the Client</h3>
1164 <p>NOTE: <strong>This problem can occur only if you have explicitly
1165 configured the server to request a client certificate (using
1166 either the <a href="#parameters.needClientAuth"><span class="prop">needClientAuth</span></a> or
1167 <a href="#parameters.wantClientAuth"><span class="prop">wantClientAuth</span></a>
1168 property)</strong>.
1169 </p>
1170
1171 <p>When the client attempts to connect to the logging
1172 server, you see the following exception in the client's log:
1173 </p>
1174
1175 <p><em>javax.net.ssl.SSLHandshakeException: Received fatal
1176 alert: ...</em>
1177 </p>
1178
1179 <p>The remainder of the exception message will usually provide a
1180 code that indicates why the server rejected the client's
1181 certificate.
1182 </p>
1183 <table class="bodyTable striped">
1184 <tr>
1185 <th>Code</th>
1186 <th>Description</th>
1187 </tr>
1188 <tr>
1189 <td><code>certificate_unknown</code></td>
1190 <td>Usually indicates that the server's trust store has not
1191 been properly configured.
1192 </td>
1193 </tr>
1194 <tr>
1195 <td><code>certificate_expired</code></td>
1196 <td>Indicates that the client's certificate has expired and
1197 needs to be replaced.
1198 </td>
1199 </tr>
1200 <tr>
1201 <td><code>certificate_revoked</code></td>
1202 <td>Indicates that the issuing certification authority (CA)
1203 has revoked the client's certificate and the certificate
1204 needs to be replaced.
1205 </td>
1206 </tr>
1207 </table>
1208
1209 <h4>Solutions</h4>
1210 <p>If the client's log message is reporting <code>bad_certificate</code>
1211 then using either the <a href="#basicConfig.trustStore">Trust Store system
1212 properties</a> or the <a href="#ssl.trustStore">
1213 <span class="prop">trustStore</span></a> property of the
1214 server component's <span class="prop">ssl</span> property,
1215 you must specify the location and password for the trust
1216 store containing the client's self-signed certificate or
1217 the issuing certificate authority's root certificate.
1218 </p>
1219
1220 <p>If the server's log message is reporting
1221 <code>certificate_expired</code> or <code>certificate_revoked</code>
1222 the client needs a new certificate. The new certificate
1223 and associated private key needs to be placed in the key store
1224 specified in the client's configuration. And, if using
1225 a self-signed client certificate, the client's certificate also
1226 needs to be placed in the trust store specified in the
1227 servers's configuration.
1228 </p>
1229
1230 <h3>Client and Server Cannot Agree on a Protocol</h3>
1231 <p>NOTE: <strong>This problem usually occurs only when you are
1232 explicitly
1233 <a href="#parameters.excludedProtocols">excluding</a> or
1234 <a href="#parameters.includedProtocols">including</a> SSL
1235 protocols in your configuration</strong>.
1236 </p>
1237
1238 <p>When the client attempts to connect to the server, you see
1239 the following exception in the log:</p>
1240
1241 <p><em>javax.net.ssl.SSLHandshakeException: Received fatal
1242 alert: handshake_failure</em>
1243 </p>
1244
1245 <p>The server's log message is usually more descriptive. For
1246 example:</p>
1247
1248 <p><em>javax.net.ssl.SSLHandshakeException: SSLv2Hello is disabled</em>
1249 </p>
1250
1251 <p>Generally, this means that you have excluded a protocol from
1252 one of the peers and not the other.</p>
1253
1254 <h4>Solution</h4>
1255 <p>Check the values specified for the
1256 <a href="#parameters.excludedProtocols"><span class="prop">excludedProtocols</span></a> and
1257 <a href="#parameters.includedProtocols"><span class="prop">includedProtocols</span></a>
1258 properties on both the server and client.
1259 </p>
1260
1261 <h3>Client and Server Cannot Agree on a Cipher Suite</h3>
1262 <p>NOTE: <strong>This problem usually occurs only when you are
1263 explicitly
1264 <a href="#parameters.excludedCipherSuites">excluding</a> or
1265 <a href="#parameters.includedCipherSuites">including</a> SSL
1266 cipher suites in your configuration</strong>.
1267 </p>
1268
1269 <p>When the client attempts to connect to the
1270 server, you see the following exception in the log:
1271 </p>
1272
1273 <p><em>javax.net.ssl.SSLHandshakeException: Received fatal
1274 alert: handshake_failure</em>
1275 </p>
1276
1277 <p>The server's log message is usually more descriptive:
1278 </p>
1279
1280 <p><em>javax.net.ssl.SSLHandshakeException: no cipher suites in common</em>
1281 </p>
1282
1283 <p>This means that you have configured the cipher suites on the
1284 server and client such that the intersection
1285 of their respective sets of enabled cipher suites is empty.</p>
1286
1287 <h4>Solution</h4>
1288 <p>Check the values specified for the
1289 <a href="#parameters.excludedCipherSuites"><span class="prop">excludedCipherSuites</span></a> and
1290 <a href="#parameters.includedCipherSuites"><span class="prop">includedCipherSuites</span></a>
1291 properties on both the server and client.
1292 </p>
1293
1294 <script src="../templates/footer.js" type="text/javascript"></script>
1295
1296 </div>
1297 </body>
1298 </html>