Pages

Solving "Unable to Connect to SSL Services due to PKIX Path Building Failed sun.security.provider.certpath.SunCertPathBuilder" Exception

Problem

In this post I explain how to solve the issue that throws the following exception.

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
 at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1476)
 at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
 at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
 at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:846)
 at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
 at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
 at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:815)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1025)
 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1038)
 at InstallCert.main(InstallCert.java:63)

Solution

The reason for this exception is that the certificate of one or both applications is not trusted by the other application, due to not being imported into the trust store of the JVM running that application. We need to install the SSL certificates that the application needs to connect over SSL, into our local keystore. 

First download InstallCert from here and compile the InstallCert.java.

javac InstallCert.java
Assume that we need to download the SSL certificate of the server at https://example.com.
To add it to your local store. Run:
java InstallCert example.com:443
These commands will create a file called jssecacerts and will be updating it with more SSL certificates every time you want to add a certificate. 
Copy this file to your java security folder (usually at $JAVA_HOME/jre/lib/security):
sudo cp jssecacerts $JAVA_HOME/jre/lib/security
And now our Java applications will be able to connect to the servers that we allowed over SSL.

Additional Operations:

Access server, and retrieve certificate.
java InstallCert [host]:[port]

Extract certificate from created jssecacerts keystore
keytool -exportcert -alias [host]-1 -keystore jssecacerts -storepass changeit -file [host].cer

Import certificate into system keystore
keytool -importcert -alias [host] -keystore [path to system keystore] -storepass changeit -file [host].cer

WSO2 Clustering Briefings

Intro

  • High availability AND Scaling
  • How to?
    • Vertical scaling
    • Horizontal scaling - have a load balancer
  • Clustering for the scalability
    • nodes should be stateless
  • Clustering for availability
    • Session/state replication
  • TCP communication is involved. TCP communication is done via sockets. So it requires IP/port for each member node.
  • Static membership - can't add nodes without restarting the cluster
  • Dynamic membership - nodes can join/leave
  • Hybrid membership  - dynamic nodes revolves around the static members
Membership management- membership discovery
1. Multicast based membership mgt
    • After the discovery, communication is happening p2p
    • Only for testing purposes
2. Well-known Address based(WKA)
    • no need of public channel
    • At-least 2 well-known members
    • Well-known members notify the newly joined dynamic members
  • In cloud and internet you can't multicast, so WKA is preferred
  • Hazlecast, apache tribes handles membership mgt
  • Hazlecast
    • Clustering and highly scalable data distribution
    • Partitions the data-> in-memory data grid which is distributed too
  • Auto-scaling
    • allocation/deallocation of nodes based on the current load
  • Deployment types
    • Single node
    • Primary-secondary
      • Have a secondary node in case of primary node failures
    • Primary-secondary with multiple LB
    • multi datacenters
  • Management and Worker nodes separation
    • Management nodes controls the cluster, upload artifacts, do the management work etc.
    • Workers perform the main work, shouldn't do any mgt work
    • This Separation is done using sub domains, mainly routing the requests based on it
    • A usecase- deployment synchronization
  • Caching- when expensive data transfers to be done
    • JCache
ELB - Elastic load balancing
  • Only HTTP traffic, not TCP
  • Proxy port
    • When multiple HTTP/HTTPs ports are there portmapping should be done - axis2.xml
  • Tenant-aware LB
    • tenant partitioning - define a tenant range
    • LB routes the tenant requests to the relevant cluster based on the tenant range
  • Private Jet Mode - dont share the resources with others - done using tenant range
  • loadbalancer.conf
LB Cluster
In case of failure of LB node, secondary node has to learn from the beginning. To avoid this state replication is done.









Receiving an email & reading the content or attachments using WSO2 ESB

Introduction


We can receive emails that are intended for some email address of a mail server, process the content of the email including email body content, attachments etc. I am using WSO2 ESB 4.8.1 and the latest version of the product can be downloaded from here.


Enabling the Mail Transport


We should enable mail transport listeners in WSO2 ESB in order to receive emails. For that go to {ESB_HOME}/repository/conf/axis2/axis2.xml and uncomment the following line:


Configuring the Proxy Service


Configure the mail proxy with your receiving email address and the mail server settings. 
In this example my email address is wso2esb481@gmail.com and password is password.


Preparing the Attachment File

Insert the content that you want to process inside a SOAP11 envelope body into the file that should be attached. In this post I put some XML content that should be processed and the attachment file would look like this: Send the email to the specified address (in this case wso2esb481@gmail.com) and it would print something like this in the carbon console. 
As you can see, the content of the attachment and email body content are printed in the carbon console. You can process them as you wish.




Setting up a MySQL server for WSO2 API Manager

Introduction

WSO2 API Manager is a complete solution for designing and publishing APIs, creating and managing a developer community, and for scalably routing API traffic. Download and try the product here. 
API Manager uses three databases. The following databases are shared among the server nodes.
  • User Manager Database - Stores information related to users and user roles. This information is shared among the Key Manager Server, Store, and Publisher. Users can access the Publisher for API creation and the Store for consuming the APIs.
  • API Manager Database - Stores information related to the APIs along with the API subscription details. The Key Manager Server uses this database to store user access tokens that are used for verification of API calls.
  • Registry Database - Shares information between the Publisher and Store. When an API is published through the Publisher, it is made available in the Store via the sharing registry database.

In this post we are going to install MySQL as the database server, create the above three databases and configure the WSO2AM 1.7.0 to use the MySQL server 5.5.

Installing and Configuring

  1. Download and install MySQL Server. Start and run the MySQL server.
  2. Download the MySQL JDBC driver.
  3. Unzip the downloaded MySQL driver zipped archive, and copy the MySQL JDBC driver JAR (mysql-connector-java-x.x.xx-bin.jar) into the {APIM_HOME}/repository/components/lib directory.
  4. Create the three databases using the following commands, where  is the path to any of the API Manager instances you installed, and username and password can be your intended credentials.
  5. Open the {APIM_HOME}/repository/conf/datasources/master-datasources.xml file. Enable access to the the API Manager, User Manager and Registry databases by modifying the WSO2AM_DB, WSO2UM_DB and WSO2REG_DB data sources in the master-datasources.xml file as follows:
  6. Modify the /etc/hosts entries to map the IP addresses to the data source URLs:
      • 127.0.0.1 apimgtdb.mysql-wso2.com
      • 127.0.0.1 userdb.mysql-wso2.com
      • 127.0.0.1 regdb.mysql-wso2.com
  7. To give component access to the API Manager database, open the {APIM_HOME}/repository/conf/api-manager.xml file and add the following line as the first child node of the root element (if it is not already there):
     
  8. To give access to the users database with shared permissions, open the {APIM_HOME}/repository/conf/user-mgt.xml file and add or modify the dataSource property of the  element as follows:
  9. To give access to the registry database, open the {APIM_HOME}/repository/conf/registry.xml file and modify the dataSource attribute of the  element as follows:

WSO2 ESB Performance Round 7.5

The latest round of performance testing results has been published by WSO2: WSO2 ESB Performance Round 7.5

These latest performance study has been conducted with the latest release of WSO2 ESB 4.8.1.

It compares WSO2 ESB performance against a number of leading open source ESBs. Results show the latest WSO2 ESB convincingly outperforms all other open-source ESBs, like in the case of the previous round (6.5).

Observations





The results indicate that WSO2 ESB 4.8.1 has continued to outperform all other compared ESBs in almost all scenarios.

Getting system Information via Ubuntu terminal

In addition to the system monitor we can get a detailed view of the hardware specifications and system information about the machine via the terminal using lshw command.

lshw | more

GPU information

lspci | grep -i vga

Installing Berkeley UPC on a Linux cluster

You have 3 options as mentioned in the Berkeley UPC download site.

  1. Download  Berkeley UPC runtime source distribution , build it. Then the  'upcc' compiler  will  use their HTTP-based public UPC-to-C translator during compilation. 
  2. OR download both the runtime and  UPC-to-C translator, build them, and then point the runtime at the translator. This allows to compile UPC code without the Internet hence faster compilation times.
  3. OR download both the runtime and the GCC UPC binary compiler, build them, and point the runtime at GCC UPC installation.
I go with the first option.

Please consider that you need C/C++ and MPI compilers in order to install Berkeley UPC.

1. Download the .tar from here and extract it.


2. Create a new directory to build the Berkeley UPC. I name my build directory as 'build'

mkdir build
 cd build

3. From the build directory, run the configure script in the extracted source directory. 


../berkeley_upc-2.xx.x/configure CC="" CXX="" MPI_CC=""
Replace the " " with the compilers you have installed in the machine. In my case it's gcc, g++ and mpicc. If you have more efficient compilers please use them. It would take sometime to configure.  
e.g. ../berkeley_upc-2.xx.x/configure CC=gcc CXX=g++ MPI_CC=mpicc

4. Using the Makefile in the build directory, build the Berkeley upc source.
make

5. The Berkeley UPC compiler operates by invoking a UPC-to-C translator and then using a backend C compiler to generate native objects. After building the source you can define the UPC-C translator location. You can either build a local translator(as I explain next) or use the default network translator hosted by Berkeley.

6. Building the local UPC-C translator
   6.1. Download the source from here and extract it.
   6.2. Go to the extracted directory and build the source using make.
     make
 6.3 Now you have successfully built the translator.


7. After completion of successful build, it will show you the translator location path. Copy it to the clipboard. Path would be something like this.
~/upc/berkeley_upc_translator-2.18.0/open64/osprey1.0/targia32_ia64_nodebug

8. Move back to the build directory of Berkeley UPC compiler and you can see 2 folders called 'dbg' and 'opt'. In each folder there is a configuration file called 'upcc.conf'. Open these files in a text editor and replace the translator="path to default location" with the copied path to the location of the local UPC-C translator in the clipboard.

9. Test the Berkeley UPC build using following:
env UPCC_FLAGS= ./upcc --norc --version

This would show the specifications and version details of the UPC compiler and translator.
10. You may use the examples in the berkeley_upc-2.xx.x/upc-examples directory to test the build before installation.
11. Finally install the UPC compiler and run time.
make install 

You have completed the installation successfully. To try the compiler use:
upcc --version and upcrun commands.

2. Setting up SSH password-less log in

1. Define a common user for all the machines with the same user name and make the home directory /mirror

madhawa@node0:~$ sudo useradd -d /mirror/mpiuser -m -s /bin/bash mpiuser
madhawa@node0:~$ sudo passwd mpiuser

This would prompt for a new password for the user id "mpiuser". Do the same thing to all the machines.

2. Make the mpiuser as the owner of the /mirror

madhawa@node0:~$ sudo chown mpiuser /mirror

3. Install the SSH server in all the machines.

madhawa@node0:~$ sudo apt-get install openssh-server

4. Setup the password-less log in.

login with the new user in su mode.

madhawa@node0:~$ su mpiuser

Generate DSA key pair for the mpiuser.

mpiuser@node0:~$ ssh-keygen -t dsa

This will prompt for a passphrase. Leave it empty. 

A folder called .ssh is created in /mirror/mpiuser which contains the key file. Add this key to the authorized set of keys by issuing the following commands.

mpiuser@node0:~$ cd .ssh
mpiuser@node0:~/.ssh$ cat id_dsa.pub >> authorized_keys
mpiuser@node0:~/.ssh$ chmod 644 authorized_keys 

To test the password-less login, issue the following command on the master node and if successful, this would return the host name of the nodes without asking for password or passphrase.

mpiuser@node0:~$ ssh node1 hostname

Note: Sometimes you may be prompted to enter password for once. But it won't be required again. 





1. Setting Up the NFS on the Computer Cluster

I have 3 machines, each of which has Ubuntu 12.04 32bit installed. I have named my machine as node0, node1, node2.

Note:  If you want to rename your machines in edit the /etc/hostname file:
madhawa@node0:~$ sudo nano /etc/hosts
and replace the current machine name with your preferred name.

So let's start the setting up.

1. Define the host names by editing the /etc/hosts file:


madhawa@node0:~$ sudo nano /etc/hosts

and put the following. Note that I have removed the line 127.0.1.1 node0

127.0.0.1 localhost

10.16.32.10 node0
10.16.32.11 node1
10.16.32.12 node2

2. Install NFS server on the master node. I take the node0 as the master.

madhawa@node0:~$ sudo apt-get install nfs-kernel-server

3. Make a new directory that is to be shared among all the nodes. My shared folder is /mirror. In order to share the edit the /etc/exports file:

madhawa@node0:~$ mkdir /mirror
madhawa@node0:~$ sudo nano /etc/exports

And put the following line to set the permissions for the nfs. 

/mirror *(rw,sync)

4. Restart the server 

madhawa@node0:~$ sudo service nfs-kernel-server restart

5. Install the NFS client programs on the other machines.

madhawa@node1:~$ sudo apt-get install nfs-common

6. Mount the shared folder on the other nodes.

madhawa@node1:~$ sudo mount node0:/mirror /mirror
madhawa@node2:~$ sudo mount node0:/mirror /mirror

Note: This is the folder that is used to put the shared files required for the distributed execution. NFS enables remote mount and access to the files in another machine.




Setting up a small MPI Cluster using MPICH on Linux (Ubuntu 12.04)

In the next few posts I am going to explain my experience on how to setup a MPI cluster with 3 Linux machines. I referred several online resources, extracted information and arranged them in the posts. 

Specifications:
OS : Ubuntu 12.04 desktop or server Version
MPI : MPICH2
SSH : OpenSSH
Compiler : gcc 4.6.3
NFS

This post comes in 4 parts which describes the 4  main steps and they are as follows.

  1. Set up Network File System(NFS)
  2. Set up SSH password-less log in
  3. Install Compilers
  4. Install MPICH
So let's start!
(I'm putting the list of the references at the end of the post and I thank their authors for the great work)

Introduction to GPU computing

For those who are interested in GPU Computing and HPC, this is a good basement!

Show the world we want a phone worth keeping!


Worth spending few minutes on this! Watch the video and show your support here!

Dijsktra’s Algorithm in Java

Dijkstra’s shortest path algorithm is used to find the shortest path in a positive weighted graph from a given source to all the other nodes. There are 3 main steps of the algorithm.
 Initialization of single source – Inserting elements into required data structures and initialization
Extract Minimum – Extracting the node with the minimum value.
Generally the vertices in the graph can be stored 3 data structures: 1. Linear Array 2. Binary Heap/Priority Queue 3. Fibonacci Heap. Depending on the data structure we use the run time complexity of the algorithm differs.
Decrease key -  includes relaxation.

Dijkstra.java

Vertex.java

Edge.java



High Performance Computing Hardware

In high performance computing, it is important to know the parallel computing hardware options available for programmers when programming a computer cluster.

Distributed Memory Computing

A multiprocessor system in which each processor has its own memory. Since the the memory is distributed, message passing should be done among the individual nodes. Based on a set of processes. MPI is one such distributed memory programming platform.
Read more..

Shared Memory Computing

A multiprocessor system in which processors shares a global random access memory across the system. Based on a set of threads runs on each processor sharing the globally available memory. OpenMP is one such shared memory programming platform.

Partitioned Global Address Space (PGAS)

A combination of both shared and distributed memory programming architectures. It provides an abstraction of a globally shared memory to application level tasks. Furthermore it divides the global address space into sections called "partitions" so that individual threads can access their corresponding partition which is analogous to a distributed memory. 


Changing the username in Ubuntu/ Linux


  1. Log in using your username and password (username to be changed)
  2. Set a password for the root. Following will prompt for the new password.
    sudo passwd root
  3. Log out.exit
  4. Log in using the root account. Give the new password.
  5. If the user account of which the username is to be changed is still in use log out from that.
    pkill -KILL -u username
  6. Change the username and the home folder to the new user name.
    usermod -l -d /home/ -m
  7. Change the group name to the new group name that you want.
    groupmod -n
  8. Can check the group names using this.
    groups
  9. Better lock the root account.
  10. Log out from root and log in using the new username
  11. Done!

How to get Clear Fonts in lyx output PDF

For those who write their thesis papers, research papers or any article, Lyx is one of the most user friendly and trouble free Latex processor that can be used with latex. Usage is as easy as using any document processor like Microsoft word but lets you harness the power of Latex at the same time. But I have had a problem when generating the pdf using pdf2latex or any other tool that the font of the output pdf is somewhat unclear and blurred. To solve this do the following setting.
Document -> Settings -> Fonts -> Roman -> Latin Modern Roman

4 ways to boot/install Windows 7 USB - With or without additional tools

I have been searching for ways to install a Windows key into my USB so that I could install windows 7 without using a DVD-ROM. This article is the best, simplest and the effective one I found so far. It gives 4 ways to convert your flash drive to a bootable media with additional tools or just the command line. Hope it helps y'all.


Unsubscribe from spam emails in bulks

A clean inbox. Just one click away…for free!
Your inbox is a mess, and it’s time to admit defeat. Stop sorting through your emails, and start doing things you love again. "Unroll.me" is here to help you.
Sign up here!

Installing MPICH

For those who are interested in building up an MPI enabled cluster from the scratch, This is a very good place to start. They have used MPICH as the MPI implementation.