Friday, April 11, 2014

Patching OpenSSL for the Heartbleed Vulnerability CVE-2014-0160 in Mac OS X and Ubuntu / CentOS / Fedora

From 7th April we should update our OpennSSL version. Why? Security reasons. An OppenSSL vulnerability was disclosed which has been called one of the worst security holes in the last years. Let's do it!

OSX with MacPorts

To know your current version type: openssl version -a

myMac:~ Myself$ openssl version -a
OpenSSL 1.0.1f 6 Jan 2014

Opps, I have a bug in my system. It's time to update and upgrade the OpenSSL:
$ sudo port selfupdate
$ sudo port upgrade oppenssl
MyMac:~ Myself$ sudo port upgrade openssl 
--->  Computing dependencies for openssl
--->  Fetching archive for openssl
--->  Attempting to fetch openssl-1.0.1g_0.darwin_13.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/openssl
--->  Attempting to fetch openssl-1.0.1g_0.darwin_13.x86_64.tbz2.rmd160 from http://nue.de.packages.macports.org/macports/packages/openssl
--->  Installing openssl @1.0.1g_0
--->  Cleaning openssl
--->  Computing dependencies for openssl
--->  Deactivating openssl @1.0.1f_0
--->  Cleaning openssl
--->  Activating openssl @1.0.1g_0
--->  Cleaning openssl
--->  Updating database of binaries: 100.0%
--->  Scanning binaries for linking errors: 100.0%

--->  No broken files found.

Now we can check again our version to be sure that we have an updated openssl version:

MyMac:~ Myself$ openssl version -a
OpenSSL 1.0.1g 7 Apr 2014

Ubuntu:

$ sudo apt-get update
$ sudo apt-get upgrade
$ openssl version -a

CentOS/Fedora

$ sudo yum -y install openssl
$ openssl version -a

Hope help!

Thursday, April 10, 2014

How to get the internal IP address of our machine using Java (for Raspberry Pi)


Hello, today... more Java

First of all, eth0 is your ethernet card. They are labelled "ethX" starting with an X of 0, so if you had two ethernet cards, the second would be "eth1".

Now, the idea is to get the IP address of my machine (small Raspberry Pi) using Java.  Normally, we can try simply with InetAddress.getLocalHost(). But if we have more than one ethernet card or a loop perhaps this method doesn't work.

A possible solution could be:
InetAddress internalIP;

Enumeration nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
    if(netint.getName().equals("eth0")) {
        Enumeration inetAddresses = netint.getInetAddresses();
        for (InetAddress inetAddress : Collections.list(inetAddresses)) {
            internalIP = inetAddress;
            break;
        }
    }
}

Now we can use internalIP.getHostAddress() to show the IP address like a string.

Hope help!!