Showing posts with label Weblogic. Show all posts
Showing posts with label Weblogic. Show all posts

November 21, 2015

How to import certificates to weblogic server

Below is the procedure to be done to import certificates to weblogic server.
  • Import or download the certificate to a local folder ex: D:\myprojects\Docs\certs\fap0424.cer ; where fap0424.cer is my certificate
  • Using below command, import the certificate to the weblogic server
keytool -import -alias fap0424  -file D:\myprojects\Docs\certs\fap0424.cer -keystore C:\Oracle\Middleware\JDev11.1.1.7.1\wlserver_10.3\server\lib\DemoTrust.jks
  • To verify the import, use below command which list out all the certificates in the weblogic server
keytool -list -alias fap0424 -keystore C:\Oracle\Middleware\JDev11.1.1.7.1\wlserver_10.3\server\lib\DemoTrust.jks

In the above example the file path C:\Oracle\Middleware\JDev11.1.1.7.1\wlserver_10.3\server\lib\DemoTrust.jks represents the weblogic file to which we should export our certificate.

April 4, 2015

javax.net.ssl.SSLKeyException: failed hostname verification

Problem:
When my adf web application executing a web service call, I got the below error which was failed to verify the hostname.

javax.xml.ws.WebServiceException: javax.net.ssl.SSLKeyException: [Security:090504]Certificate chain received from XXXXXXXXXXXX.demos.com - YY.YY.YY.YY failed hostname verification check. Certificate contained *.demos.com but check expected XXXXXXXXXXXX.demos.com


where XXXXXXXXXXXX.demos.com is my host name.

Solution:

To avoid this error, we have two solutions. One is to make weblogic ignore the host name verification and another one is to ignore verification through code. We can use either of these solutions to avoid the above error.

The first way is the weblogic should ignore the host name verification. To do this, follow the below procedure.

  • Login to weblogic console
  • Go to Servers, then click on the server name (in my case the name is DefaultServer)
  • Go to SSL tab
  • Under the Advanced section, you can see the property "Hostname Verification"
  • By default, it value is "BEA Hostname Verifier". Change this value to "None"
  • Click on Save and restart the server
  • Run again the application now

And the Second way is to write a code snippet to ignore verification of host name. Below is the java code to do so.
     
TrustManager[] trustAllCerts =
            new TrustManager[] { new X509TrustManager() {
                public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                    return null;
                }

                public void checkClientTrusted(java.security.cert.X509Certificate[] certs,
                                               String authType) {
                }

                public void checkServerTrusted(java.security.cert.X509Certificate[] certs,
                                               String authType) {
                }
            } };

        SSLContext sc = SSLContext.getInstance("SSL");
        sc.init(null, trustAllCerts, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

        // Create all-trusting host name verifier
        HostnameVerifier allHostsValid = new HostnameVerifier() {
            public boolean verify(String hostname, SSLSession session) {
                System.out.println("HostnameVerifier - "+hostname+" Session: "+session);
                return true;
            }
        };
        HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);


Note: These two ways are only for testing purpose, may not suggestible to use in production environment.

April 3, 2015

oracle.security.jps.JpsRuntimeException: Cannot read from policy store

Problem:
While running my integrated weblogic, I got an error like below.

oracle.security.jps.JpsRuntimeException: Cannot read from policy store. Reason is PolicyStore Error, javax.xml.stream.XMLStreamException: Error at line:332 col:25  ' '

Solution:
To solve this error, the weblogic domain should be deleted and start the weblogic again. Then it will create a fresh domain.

October 6, 2014

How to delete MDS content of an application?

Below steps tell you how to delete MDS content of an application from EM console. 
  • Login to weblogic EM console
  • Under the domain (on left hand side), expand "Metadata Repositories" and select the target MDS. In this example, it is "mds-SpacesDS"
                               
  • You can see the list of partitions under the section "Repository Partitions" 
  • Select the target partition
                    
  • Click on "Delete..." button on top of the list and confirm
  • MDS content of the partition will be deleted.

September 30, 2014

Undeploy app from EM console

This post is to tell how to undeploy an installed application from EM (Enterprise Manager) console.
Below are the steps to do the same.

  • Login into em console
  • Expand the domain
  • Expand Application Deployments and then Internal Applications
  • Select the application and right click on that
  • From Application Deployment menu, select "Undeploy..." option (see the below image)
  • It will open the confirmation screen, click undeploy button on top of the screen and proceed the instructions to undeploy the app.


March 12, 2013

Enable logging in Weblogic to print System.out.println()



I have a web application in which I have given “System.out.println()” statements to print information, but I could not see these statements in weblogic logs. To get these print statements in weblogic logs, “stdout” should be enabled in the weblogic server log. To check this, we can follow the below procedure.

  • Go to weblogic and select the server (Ex: AdminServer) in which you want to enable this logging
  • Go to “Logging” tab of the server
  • Click on “Advanced” option
  • Enable or Check in the option “Redirect stdout logging enabledif it is not checked in
  • And also Check in the option “Redirect stderr logging enabledto print error statements in the server logs
  • After enabling these options, the screen would look as below  



  • Click on Save button and Restart the server instance