Monday, May 12, 2008

Java and self-signed SSL certificates

It is very common in test environments to employ self-signed SSL certificates in HTTP servers (e.g., Apache HTTPD, Tomcat) rather than certificates issued by trusted commercial Certification Authorities. When trying to open a SSL connection to a host using a self-signed SSL certificate, however, the JSSE throws the following exception:
javax.net.ssl.SSLHandshakeException: (...)
unable to find valid certification path to requested target

Andreas Sterbenz provides a very nice guide that shows you how to add a self-signed SSL certificate to the keystore with your app's trusted certificates. It basically comes down to 4 steps:
  1. Use his InstallCert java program to make a request to the host with the SSL certificate you want to trust. Assuming the host address "somehost.com" and the port for the SSL connection is "8443", you should compile the InstallCert.java file and execute it with these parameters:
    java InstallCert somehost.com:8443
  2. Following the instructions on the guide, after the exception you should receive a list of SSL certificates from the host. If you decide to trust one of them, pick the number corresponding to that certificate.
  3. If you picked one of the available certificates, the InstallCert program will generate a file called jssecacerts on the directory where you executed the program.
  4. To use the newly added certificate when establishing SSL connections to "somehost.com", add the following line your java application:
    System.setProperty("javax.net.ssl.trustStore", "path/to/jssecacerts");

    where "path/to/" represents the full path to your jssecacerts file
And that's it! Now you can try creating an HttpClient and performing an HTTP/GET operation to see it working :-)

Friday, April 25, 2008

Run, baby, run

Haven't had much time for personal blogging lately. Some news for the last few weeks:
  • Moved back to Brazil. Meeting my family and friends again after almost a year and a half away from home was great :-)
  • Finished reading the last two "gold edition" Sandmans that came out in Brazil. Volume 9 (The Kindly Ones) is now officially my favorite from the series.
  • Was accepted at the Google Summer of Code! I will be working with the Globus Alliance on a project entitled "SAML Holder-of-Key Authentication for HTTP Single Sign-On in GridShib". Fancy, huh?
  • Our team solved 5 out of 8 problems on our first coding marathon at the "Programming Challenges" lecture. Not bad considering we met each other today, and only one team solved 6 (and at the very last minute!).
That's it for now. A very nice week to anyone who reads this :-)

Wednesday, March 26, 2008

Leaving to Brazil and ACM ICPC

Almost a month without writing :-)

Lately I've been a little busy: preparing to leave France and come back to Brazil, wrapping up some documentation for my internship, a couple of university assignments..

Speaking of which, this semester I am attending an elective course on "Programming Challenges" at UFRGS (my university). It is a very interesting lecture that prepares you for the ACM International Collegiate Programming Contest. Each week we learn/revise problem solving techniques (algorithms, data structures, and so on) and we submit our answers for a set of problems to the University of Valladolid online judge. So far it has been challenging and very interesting. For those interested, I will keep posting my solutions on the code snippets website, under the acm tag.

A nice and fun week to all who read this :-)

Monday, February 25, 2008

Brushing up on C (Part 1)

A while ago I read an article on how a certain professor believes teaching Java as a first programming language is 'damaging' to CS students.

Well, I totally agree.

But I also don't think learning Pascal (as in my university..) is the best solution ever. The students get used to code their projects in a language totally obsolete (ok, there's delphi.. :P), and are supposed to "learn how to program in any language". It's true that with a language like Pascal you are able to focus mainly on the algorithm itself. However, the freedom you have in C to do nasty things (pointer arithmetic, anyone?) is definitely not present in Pascal. Though I was a "good" Pascal programmer (haha what a joke...), I remember I had big problems with C. And after spending several years mostly coding in Java, I still do.

So I decided to "brush up" on my C skills. I will start by posting one of the most useful pieces of code ever, which can be easily adapted to any programming language (talk about language independence huh, Dr. Edmond Schonberg?)

And here you go: a simple way to check command line arguments, in C.

(Ha, I bet you were expecting some awesome data structure or a really cool algorithm! Well, I doubt you can find a solution like the one above that doesn't involve a bunch of stupid "else if" statements :D)

Wednesday, February 20, 2008

On the ultimate personality test

Et voilĂ !

Taken from Coster's blog :)

On more creative spam

A new one today:

Dear Joana M. Fonseca,

We would like to inform you about the "Project on an Integral and Integrative Perspective on Engineering and Meta-Engineering" which will mainly contain several publications, empirical research, and conferences organization. We appreciate if you can share your opinion with us with regards to this issue. You can do so by filling the inquiry form at:
http://www.iiis.org/inquiry/b.asp?t=u02&e=MYEMAIL@NOSPAM.UNI.BR
It will require no more than one minute of your valuable time.

We would also like to inform you that, in the context of this project, we have already decided to 1) publish a book with the tentative title of "Reflections on Engineering and Meta-Engineering for the XXI Century", and 2) organize The First International Multi-Conference on Engineering and Technological Innovation (IMETI 2008; http://www.infocybereng.org/imeti2008). Consequently, any information regarding your potential participation in any of these two activities will be highly appreciated.

The rational supporting and motivating this project can be found in the article "The Essence of Engineering and Meta-Engineering: A Work in Progress" available at http://www.iiis.org/Nagib-Callaos/Engineering-and-Meta-Engineering

Best regards,

Prof. Nagib C.Callaos
IMETI 2008 General Chair
www.sciiis.org/Nagib-Callaos

I kept receiving congratulations for having a paper accepted in a GESTS conference, but this is the first time I get emails from the famous Nagib Callaos! :D

On nice and useful diagrams

As an occasional UML user, I find it sometimes troublesome to express more general software architecture concepts using only class, activity or even deployment diagrams. When the target audience does not have much IT knowledge, it may be difficult to present ideas by using diagrams intended for representing "executable" code. On the other hand, a set of boxes with no direct semantics associated to it might require a lot of effort (or presentation skills) to make it understandable.

I recently came across an interesting solution for this kind of problem, the Fundamental Modeling Concepts (or just FMC). From the website:

"It (FMC) enables people to communicate the concepts and structures of complex informational systems in an efficient way among the different types of stakeholders. A universal notation originating from existing standards, easy to learn and to apply, is defined to visualize the structures and to communicate in a coherent way. In contrast to most of the visualization and modeling standards of today it focuses on human comprehension of complex systems on all levels of abstraction by clearly separating conceptual structures from implementation structures."

Besides, you can make some really nice and understandable diagrams like this one. It definitely seems worth giving a quick look :D