SSL Certificate, Chromed

It’s not a long time that Chrom* browsers added a certificate management panel. Not everybody knows – in fact – that they rely on the Network Security Service tools. To add an untrusted certificate to Chrom* without using the inteface you have to add it there.
To manage NSS you need to install certutil, contained in libnss

# apt-get install libnss3-tools

The NSS certificate database is stored in your home directory:

# ls /home/rpolli/.pki/nssdb -la
total 40
drwx------ 2 rpolli rpolli  4096 2011-10-16 19:24 .
drwx------ 4 rpolli rpolli  4096 2011-10-16 19:15 ..
-rw------- 1 rpolli rpolli 10240 2011-10-16 19:24 cert9.db
-rw------- 1 rpolli rpolli 13312 2011-10-16 19:24 key4.db
-rw------- 1 rpolli rpolli   529 2011-10-16 19:18 pkcs11.txt

You can list contained certificates with

# certutil -d sql:$HOME/.pki/nssdb  -L

Certificate Nickname                                         Trust Attributes
SSL,S/MIME,JAR/XPI

Get your certificate from your site with

#openssl s_client -connect www.mysite.org:443

you can script it a bit

# echo quit | openssl s_client -connect www.mysite.org:443 |& sed -ne '/--BEGIN/,/--END/p' > /tmp/mycert.pem

Convert the cert with

# openssl x509 -in /tmp/mycert.pem -inform PEM -outform DER -out /tmp/mycert.der

And add new certificates (in DER format)

# certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n www.mysite.it  -i /tmp/mycert.der

Now restart chrome and enjoy!

Jndi connection pooling: a common pitfall

When enabling jndi connection pooling with java, you have to set just this context property


// Enable connection pooling
env.put("com.sun.jndi.ldap.connect.pool", "true");

But if you’re using SSL, Anonimous bind or MD5 auth, you have to specify some System properties too

com.sun.jndi.ldap.connect.pool.protocol="plain ssl"
com.sun.jndi.ldap.connect.pool.authentication="none simple DIGEST-MD5"

or ssl, anonymous and md5 connections will be excluded from the pool

info here

Impossibile salvare documenti Internet Explorer da un sito Web SSL o con Basic Auth

Nel corso dello sviluppo di una demo per un cliente siamo incappati in un errore stranissimo, quando si tentava di scaricare il file certificate.p12 appariva una finestra con l’errore “Impossibile aprire il sito Internet. Sito non disponibile o non trovato. Riprovare.” la cosa si verificava solo con l’uso di Internet Explorer (6 o 7)… naturalmente la webapp funzionava correttamente con Firefox, Safari, Opera ed anche col nuovissimo Chrome (maledetta Microsoft!!!!)

abbiamo iniziato una ricerca con google e siamo giunti alla pagina http://support.microsoft.com/kb/316431/it e http://support.microsoft.com/kb/222064 dove si parlava di un problema analogo ma non uguale, qui gli incriminati erano 2 header della response:

Pragma: no-cache
Cache-control: no-cache,max-age=0,must-revalidate

Il problema è che nel codice non erano impostati nè l’uno nè l’altro? abbiamo controllato però il pacchetto in response con tcpdump è gli header effettivamente erano presenti…. non restava che capire chi inseriva questi header… siamo giunti alla pagina http://wiki.jboss.org/wiki/DownloadSSLAndIE6 dove si capisce che è l’application server ad aggiungere tali tag, delle due soluzioni abbiamo adottato la piu semplice cioè quella di aggiungere nel codice

response.setHeader("Cache-Control", "cache, must-revalidate");
response.setHeader("Pragma", "public");

in questo modo l’application server (JBoss e Tomcat hanno lo stesso comportamento) non sovrascrive gli header ed è possibile scaricare il file anche da IE…. ;-)