Wednesday, 25 February 2015

An SSL Truster

Should you wish, when testing say, to trust all ssl certificates:



import com.mediagraft.shared.utils.UtilsHandbag;

 * Modify the JVM wide SSL trusting so that locally signed https urls, and others, are
 * no longer rejected.
 * Use with care as the JVM should not be used in production after activation.
public class JvmSslTruster {

  private static boolean activated_;

  private static X509TrustManager allTrustingManager_ = new X509TrustManager() {

    public[] getAcceptedIssuers() {
      return null;

    public void checkClientTrusted([] certs, String authType) {

    public void checkServerTrusted([] certs, String authType) {

  public static SSLSocketFactory trustingSSLFactory() {
    SSLContext sc = null;
    try {
      sc = SSLContext.getInstance("SSL");
      sc.init(null, new TrustManager[]{allTrustingManager_}, new;
      new URL(UtilsHandbag.getSecureApplicationURL()); //Force loading of installed trust manager
    catch (Exception e) {
      throw new RuntimeException("Unhandled exception", e);
    return sc.getSocketFactory();

  public static void startTrusting() {
    if (!activated_) {
      activated_ = true;

  private JvmSslTruster() {

Tuesday, 17 February 2015

Restoring user groups once no longer in sudoers

Ubuntu thinks it is neat not to have a password on root. Hmm.

It is easy to remove yourself from all groups in linux, I did it like this:

$ useradd -G docker timp

I thought that might add timp to the group docker, which indeed it does, but it also removes you from adm,cdrom,lpadmin,sudo,dip,plugdev,video,audio which you were previously in.

As you are no longer in sudoers you cannot add yourself back.

Getting a root shell using RefiT

What we now need to get to is a root shell. Googling did not help.

I have Ubuntu 14.04 LTS installed as a dual boot on my MacBookPro (2011). I installed it using rEFIt.

My normal boot is power up, select RefiT, select most recent Ubuntu, press Enter.

To change the grub boot command instead of Enter press F2 (or +). You now have three options, one of which is single user: this hangs for me. Move to the 'Standard Boot' and again press F2 rather than Enter. This enables you to edit the kernel string. I tried adding Single, single, s, init=/bin/bash, init=/bin/sh, 5, 3 and finally 1.

By adding 1 to the grub kernel line you are telling the machine to boot up only to run level one.

This will boot to a root prompt! Now to add yourself back to your groups:

$ usermod -G docker,adm,cdrom,lpadmin,sudo,dip,plugdev,video,audio timp

Whilst we are here:

$ passwd root

Hope this helps, I hope I don't need it again!

Never use useradd always use adduser