{"id":5000,"date":"2015-07-31T10:21:56","date_gmt":"2015-07-31T02:21:56","guid":{"rendered":"http:\/\/rmohan.com\/?p=5000"},"modified":"2015-07-31T10:21:56","modified_gmt":"2015-07-31T02:21:56","slug":"weblogic-server-ssl","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=5000","title":{"rendered":"WebLogic Server SSL"},"content":{"rendered":"<p><b>One-way SSL<\/b><\/p>\n<p>One-way SSL simply means that only the server certificate passes from the server to the client but not the other way around. Thus, only the server is authenticated. If we trust the server certificate&#8217;s issuer, we can establish an SSL link between our browser and the server [3].<\/p>\n<p><b>Two-way SSL<\/b><\/p>\n<p>When both client and server pass certificates to each other to establish an SSL link, we have mutual authentication via two-way SSL. Both sides now know the identity of the other from their respective certificates. The important thing to realize here is that, while the conditions for one-way SSL remain, the mirrored conditions also apply. In other words, the server also has to trust the issuer of the client certificate. Mutual authentication just means that both sides must trust each other. This forms the basis of Public Key Infrastructure [3].<\/p>\n<p><b>Fundamentals of PKI<\/b><\/p>\n<p>Public Key Infrastructure is a computerized form of message encryption using two keys; one is public and used by the sender to encrypt the message, the other is private and used by the recipient to decrypt the message [1]. It is essentially an arrangement surrounding the issuance of digital certificates and assignment of public keys. The issuance of a digital certificate is ultimately done by a certification authority as the result of the PKI process, which includes the binding of public keys to subscribing user identities after such identities have been validated.<\/p>\n<p>The actual verification of user identities can be done by the certification authority itself, or by a separate registration authority. Once issued, however, the certification authority stamps and seals the PKI certificate with its unique digital signature. As a result the certificate holder is able to secure network communications and online transactions, as well as provide trusted third party, PKI -based, authentication of its business identity [2].<\/p>\n<p><b>Configuration<\/b><\/p>\n<p>Steps to configure CLIENT-CERT authentication-<\/p>\n<p>Step 1: Configure two-way SSL in WebLogic Server<br \/>\nStep 2: Configure Default Identity Asserter<br \/>\nStep 3: Configure Web Application<br \/>\nStep 4: Test the configuration<\/p>\n<p><b>Configure Two-Way SSL in WebLogic Server<\/b><\/p>\n<p>First, we will test with Demo Identity and Demo Trust Store provided with WebLogic server. Later, we will discuss about configuring Custom Identity and Custom Trust Store.<\/p>\n<p><i>Note: Demo Identity and Demo Trust Store should not be used in production environment.<\/i><\/p>\n<p><b>Load BEA Test CA Certificate into Browser<\/b><\/p>\n<p>Out of the box, WebLogic will present a certificate signed by the BEA test CA. You&#8217;ll need to add that CA certificate to your browser so that the server certificate will be trusted. Note that what you want to add to your browser is the certificate of the CA that issued the server certificate- not the server certificate itself. If you don&#8217;t add the CA certificate, SSL will still work but you will be prompted by your browser about an untrusted certificate [3].<\/p>\n<p>To load the test CA certificate into your browser (Firefox 3.0 in this case) follow these steps-<br \/>\nStep 1: Go to Tools -&gt; Options<br \/>\nStep 2: Select Advanced -&gt; Encryption<br \/>\nStep 3: Click View Certificates<br \/>\nStep 4: Select Authorities<br \/>\nStep 5: Click Import<br \/>\nStep 6: Select\u00a0 $BEA_HOME\/wlserver_10.3\/server\/lib\/CertGenCA.der<br \/>\nStep 7: Select &#8220;Trust this CA to identify web sites&#8221;<br \/>\nStep 8: Click OK to save the settings.<\/p>\n<p>Your browser will now trust certificates issued from the BEA test CA.<\/p>\n<p><i>Note: Later, when you are done experimenting with the test certificate, be sure to remove the test CA certificate from your browser.<\/i><\/p>\n<p><b>Create a Client Certificate<\/b><\/p>\n<p>We will use a utility provided by BEA called <i>CertGen <\/i>to create a client certificate. This certificate will be issued by the BEA demo CA just like the demo server was. We will configure WLS to trust this client certificate when it is presented. To reiterate, the server trusts the client certificate issuer, not the client certificate directly [3].<\/p>\n<p>To generate client certificate and keystore, follow the steps given below-<\/p>\n<p>Step 1: Run $BEA_HOME\/wlserver_10.3\/server\/bin\/setWLSEnv.sh<br \/>\nStep 2: Use CertGen to create a client certificate as follows:<\/p>\n<p>java utils.CertGen -certfile user.cer -keyfile userkey.key -keyfilepass weblogic -cn user<\/p>\n<p>The CertGen command creates both the private key and certificate for the user specified as the CN (Common Name). The files are created in DER and PEM formats. Most browsers don&#8217;t recognize PEM\/DER files, so we need to convert the key and certificate into a PKCS #12 file.<\/p>\n<p>Step 3: Import key and certificate into a keystore of type PKCS#12 as follows:<\/p>\n<p>java utils.ImportPrivateKey -keystore keystore.p12 -storepass weblogic -storetype pkcs12<br \/>\n-keypass weblogic -alias newalias -certfile user.cer.pem<br \/>\n-keyfile userkey.key.pem -keyfilepass weblogic<\/p>\n<p><b>Load Client Certificate into Browser <\/b><\/p>\n<p>The procedure for loading client certificates is almost the same as loading the CA certificate:<br \/>\nStep 1: Go to Tools -&gt; Options<br \/>\nStep 2: Select Advanced -&gt; Encryption<br \/>\nStep 3: Click View Certificates<br \/>\nStep 4: Select Your Certificates<br \/>\nStep 5: Click Import<br \/>\nStep 6: Select keystore.p12 (keystore generated in the previous step)<br \/>\nStep 7: Enter the store password (weblogic in the example)<br \/>\nStep 8: Click OK to save the settings.<\/p>\n<p><b>Enforce Client Certificates over Two-Way SSL<\/b><\/p>\n<p>To configure two-way SSL, demo identity store, trust store and enforce client certificates, follow the steps given below-<br \/>\nStep 1: Login to WebLogic Server Admin Console<br \/>\nStep 2: Select domain -&gt; Environment -&gt; Servers<br \/>\nStep 3: Select the server (For example: AdminServer)<br \/>\nStep 4: Ensure that SSL Listen Port is enabled (take a note of SSL port)<br \/>\nStep 5: Save the settings<br \/>\nStep 6: Select Keystores tab<br \/>\nStep 7: Select Keystores as Demo Identity and Demo Trust<br \/>\nStep 8: Save the settings<br \/>\nStep 9: Select SSL tab<br \/>\nStep 10: Select Identity and Trust Locations as Keystores<br \/>\nStep 11: Save the settings<br \/>\nStep 12: Click on Advanced in SSL tab<br \/>\nStep 13: Select Two Way Client Cert Behavior as Client Certs Requested and Enforced<br \/>\nStep 14: Restart WebLogic Server for the changes to take effect.<\/p>\n<p>At this point, the server certificate is trusted by the browser since the browser trusts the test CA. The server is configured to trust the test CA, too, since it&#8217;s using the DemoTrust keystore. If the browser has a client certificate issued from the test CA, all should be well and SSL should work.<\/p>\n<p>To test it, navigate to the WebLogic Console over SSL (https:\/\/localhost:7002\/console). You should get prompted to supply a client certificate. Select the certificate and click OK to use it. You should then see the Console login page.<\/p>\n<p>Next, we need to configure Default Identity Asserter to allow authentication using the client certificate.<\/p>\n<p><b>Configure Default Identity Asserter<\/b><\/p>\n<p>To configure Default Identity Store to analyze X.509 client certificate and map it to a valid user, follow the steps given below-<br \/>\nStep 1: Login to WebLogic Server Admin Console<br \/>\nStep 2: Select domain -&gt; Security Realms -&gt; realm<br \/>\nStep 3: Select Providers tab<br \/>\nStep 4: Select Authentication tab<br \/>\nStep 5: Select Default Identity Asserter<br \/>\nStep 6: Select X.509 as one of the Active types by moving it to Chosen box<br \/>\nStep 7: Save the settings<br \/>\nStep 8: Select Provider Specific tab<br \/>\nStep 9: Select Use Default User Name Mapper<br \/>\nStep 10: Select the Username Mapper Attribute Type as CN<br \/>\nStep 11: Remove any delimiter for Default Username Mapper Attribute<br \/>\nStep 12: Save the settings<br \/>\nStep 13: Restart WebLogic Server for the changes to take effect<\/p>\n<p><i>Note: Default User Name Mapper will map the user name to a valid user in WebLogic user store<br \/>\nConfigure Web Application<\/i><\/p>\n<p>Web application must specify the authentication method as CLIENT-CERT in web.xml.<\/p>\n<p><b>Test the Configuration<\/b><\/p>\n<p>You are all set to test the configuration. Deploy the application to WebLogic server and request the protected resource. Server will authenticate you using the certificate and grant access to the protected resource.<\/p>\n<p><b>Custom Identity and Custom Trust<\/b><\/p>\n<p>The configuration that we just tested was with the demo identity and trust store provided by WebLogic. Instead of using the demo stores, we can use our custom identity and trust store. For development environment, we can generate a Self-Signed CA certificate using Java and WebLogic tools [See Reference 4].<\/p>\n<p>We will follow these steps to get it done-<br \/>\nStep 1: Set the Environment<br \/>\nStep 2: Generate Server Private Key and Certificate<br \/>\nStep 3: Create the Identity Store<br \/>\nStep 4: Import the Certificate into a new Trust Keystore<br \/>\nStep 5: Install Server Certificate on Client<br \/>\nStep 6: Create a Client Certificate using Self-Signed CA Certificate<br \/>\nStep 7: Bundle Certificate and Key into a Keystore<br \/>\nStep 8: Import Trusted CA Certificate and Client Certificate into Browser<br \/>\nStep 9: Configure WebLogic Server with Identity and Trust Stores<\/p>\n<p><b>Set the Environment<\/b><\/p>\n<p>Run $BEA_HOME\/wlserver_10.3\/server\/bin\/setWLSEnv.sh script to set the environment.<\/p>\n<p><b>Generate Server Private Key and Certificate<\/b><\/p>\n<p>Use CertGen to create server private key and certificate as given below:<\/p>\n<p>java utils.CertGen -selfsigned -certfile MyOwnSelfCA.cer<br \/>\n-keyfile MyOwnSelfKey.key -keyfilepass mykeypass<br \/>\n-cn &#8220;My Own Self CA&#8221;<\/p>\n<p><b>Create the Identity Store<\/b><\/p>\n<p>CertGen created a unique and secret Private Key for the server we are using and the Self-signed Root Certificate for us. But Java wants them packaged up neatly into a keystore. Fortunately BEA are a smart bunch and created a utility to help. Just to make sure there was no confusion about what it does, they called it ImportPrivateKey. Now run this-<\/p>\n<p>java utils.ImportPrivateKey -keystore MyOwnIdentityStore.jks -storepass identitypass<br \/>\n-keypass keypassword -alias trustself<br \/>\n-certfile MyOwnSelfCA.cer.pem<br \/>\n-keyfile MyOwnSelfKey.key.pem -keyfilepass mykeypass<\/p>\n<p><b>Import the Certificate into a new Trust Keystore<\/b><\/p>\n<p>When the client asks the server for a connection, the server will only allow access if it trusts the signer of the client&#8217;s certificate. This is going to be the &#8220;My Own Self CA&#8221; and to make it happen we need our trusty MyOwnSelf certificate packed up into a separate keystore called the Trust Keystore. When the client presents it&#8217;s certificate, this is where the server will look to see if it trusts the signature of the CA. Now run this-<\/p>\n<p>keytool -import -trustcacerts -alias trustself -keystore TrustMyOwnSelf.jks -file MyOwnSelfCA.cer.der -keyalg RSA<\/p>\n<p><b>Install Server Certificate on Client<\/b><\/p>\n<p>To have the client trust the server permanently, we need to install the certificate. You can follow the steps mentioned under Load BEA Test CA Certificate into Browser and import the certificate MyOwnSelfCA.cer.der into your browser. Alternatively, you can double click the certificate file and choose Install.<\/p>\n<p><b>Create a Client Certificate using Self-Signed CA Certificate<\/b><\/p>\n<p>It&#8217;s time to generate the certificate for the client. This time we want the Certificate to identify the client machine (usually the user of the machine &#8211; you can set up one client certificate per user and have more than one on a machine if you need to), and we want to ensure that the Client is linked to the Trusted CA Root Certificate we fabricated earlier. (This is why the ou (operating unit) of the client certificate must match the identity of the Trusted CA Certificate &#8211; in this case &#8220;My Own Self CA&#8221;.)<\/p>\n<p>java utils.CertGen -certfile MyClientCert.cer -keyfile MyClientKey.key -keyfilepass clientkeypass<br \/>\n-cacert MyOwnSelfCA.cer.der -cakey MyOwnSelfKey.key.der -cakeypass mykeypass<br \/>\n-cn &#8220;My Client&#8221; -e &#8220;my.own@self.com&#8221; -ou &#8220;My Own Self CA&#8221;<\/p>\n<p><b>Bundle Certificate and Key into a Keystore<\/b><\/p>\n<p>Run the command as shown below-<\/p>\n<p>java utils.ImportPrivateKey -keystore MyClientCert.p12 -storepass clientpass -storetype pkcs12<br \/>\n-keypass clientkeypass -alias clientcert -certfile MyClientCert.cer.pem<br \/>\n-keyfile MyClientKey.key.pem -keyfilepass clientkeypass<\/p>\n<p><b>Import Client Certificate into Browser<\/b><\/p>\n<p>Follow the steps mentioned under Load Client Certificate into Browser. Here, the keystore will be MyClientCert.p12 and store password will be clientpass.<br \/>\nConfigure WebLogic Server with Identity and Trust Stores<\/p>\n<p>In sections Create the Identity Store and Import the Certificate into a new Trust Keystore, we generated an Identity Keystore for Server to Client communication (to supply certificates to the client) and a Trust Keystore for Client to Server communication (to accept certificates supplied by the client). We now need to tell WebLogic to use them.<\/p>\n<p>In the WebLogic Admin Console, jump to the Keystores tab (See Enforce Client Certificates over Two-Way SSL) and choose &#8220;Custom Identity and Custom Trust&#8221;. Enter the locations of your Identity and Trust keystores, the passphrases identitypass and trustpass respectively.<\/p>\n<p>Now switch to SSL tab and enter the alias and the Private Key password (i.e &#8216;trustself&#8217; and &#8216;keypassword&#8217;, respectively, in the example). When you have saved and activated your changes in the admin console, check the WebLogic command output window to verify that your Identity and Trust keystores were loaded with no problems.<\/p>\n<p>You have now successfully configured the two-way SSL with Custom Identity and Custom Trust store. Rest of the configuration is same in both the cases. You need to configure Default Identity Asserter and make required changes to applications web.xml as mentioned earlier.<\/p>\n<p><b>Troubleshooting<\/b><\/p>\n<p>First step should be to enable the security log for your server. To enable the logs, follow the steps given below-<br \/>\nStep 1: Login to WebLogic Admin Console<br \/>\nStep 2: Select domain -&gt; Environment -&gt; Servers<br \/>\nStep 3: Select the Server (For example: AdminServer)<br \/>\nStep 4: Select Debug tab<br \/>\nStep 5: Expand the weblogic debug scope and enable security log<br \/>\nStep 6: Save the settings and restart server (if required)<\/p>\n<p>After logging is enabled, you can check the server logs and look for a possible cause.<\/p>\n<p><i>Note: You might see a lot of NoSuchAlgorithm exception that are being eaten by WebLogic server. WebLogic server looks for the best algorithm and in the process it generates those exceptions. Just ignore them.<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One-way SSL<\/p>\n<p>One-way SSL simply means that only the server certificate passes from the server to the client but not the other way around. Thus, only the server is authenticated. If we trust the server certificate&#8217;s issuer, we can establish an SSL link between our browser and the server [3].<\/p>\n<p>Two-way SSL<\/p>\n<p>When both client [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5000"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5000"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5000\/revisions"}],"predecessor-version":[{"id":5001,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5000\/revisions\/5001"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}