Expressive with experience,Correction and goal is always in mind

Very recently I started blogging wanted to share my own experience to make my self better and better

Friday, May 20, 2011

Debugging SSL

Well very recently I took pain of debugging ssl certificates in java environment and thought of keeping something in my blog to make some one's life easy.very often we run into problems of bad certificate errors on SSL clients(java,.Net etc)..This guide will help you to debug certificates errors using open ssl utility.
So here is what I went through to debug ssl connection :

So what you require :

So what you need to configure :
  • Create a OPENSSL_HOME environment variable and set it's value to installable directory.
  • Append OPENSSL_HOME/bin to System Path Variable.
  • To Test your Installation go to command prompt and type openssl --help

All set now real magic starts....

Certificate Installation :
  • Copy signed / self signed certificate into local drive
  • If signed certificate in pfx(.p12,.pfx) format convert to pem format using following commands :
    • openssl pkcs12 -in %local_drive%/xxx.yyy.p12 -out client_certs.pem
  • Enter Import password provided by certificate provider.
  • Extract private key contents from client_certs.pem by copying contents ends till END ENCRYPTED      PRIVATE KEY--- and save it into client.key fille
  • If signed certificate in pem format(.pem,.crt,.cer,)
    • Extract private key contents from client_certs.pem by copying contents ends till END ENCRYPTED PRIVATE KEY--- and save it into client.key file


Certificate Configuration :
  • Extract each certificate from client_certs.pem ends with ---END CERTIFICATE-- in separate pem file.(remember self signed certificate comes with many certificate in it.
  • Check the modulus of private key using command : openssl rsa -in client.key -noout --modulus
  • Check the modulus of pem file using following command : openssl x509 -in *.pem -noout --modulus 
  • Pick only pem file which has the same modulus as private key for making connection with openssl and save it as client.pem

Certificate Verification :
  • Run following command to make an ssl connection with message bus :
    • openssl s_client -connect mqurl:mqport -cert client.pem -key client.key

So now you have debugged SSL connection and ready to set for making connection with any clients.HORRAY!!!!!!!


Wednesday, February 2, 2011

Struts wild card search in URL

I have been completely offline with my blogs as travelling keep me busy between Pune and Mumbai..Of course I can't miss out time with my family on weekend for sure.

Recently One of my friend requested to how to perform wild card search in struts2 when search parameter is included in URL.say for example user can search on http://www.retailstore.com/catalog/shirts so now for application should search on search parameters.

So here is the easy solution :


Include following lines in struts.xml :

  <"struts.enable.SlashesInActionNames" value="true"/>
 <"struts.mapper.alwaysSelectFullNamespace" value="false"/>



Now include an action in struts.xml :

<package name="catalog" extends="struts-default" namespace="/catalog"/>
    <action name="/catalog/*" class="com.project.view.action.CatalogAction"/>
        <param name="search">{1}>
<result>/searchResult.jspresult/>
    </action>   
</package>

Now make new Action named CatalogAction :
public class CatalogAction {
   private String search ;
  public void execute(){
     //this.getSearch() will return search param from URL
  }
  //inclde getter / setter method for search
}
That is it u r done ..no need to extend any Action classes from struts extends="struts-default" does the work for u.
I have been working on spring mvc a lot but struts-2 looks promising for sure....easing out developer's life:-)