<< February 2008 | Home | April 2008 >>

How to bypass trusted host and certificate check in Java

You probably debug your secure app and have no money for getting certificate yet

I decided to share my experience, since nothing can be easily found on net, especially if you use crappy Google. Just call method below prior of using HTTPUrlConnection to connect to not trusted server when you're getting exceptions like: java.security.cert.CertificateException: Could not find trusted certificate

  public static void installAllTrustManager() {
  TrustManager[] trustAllCerts = new TrustManager[]{
            new X509TrustManager() {
             public java.security.cert.X509Certificate[] getAcceptedIssuers() {
             return null;
            }
            public void checkClientTrusted(
             java.security.cert.X509Certificate[] certs, String authType) {
            }
            public void checkServerTrusted(
             java.security.cert.X509Certificate[] certs, String authType) {
            }
            }
            };
  
  // Install the all-trusting trust manager
  try {
   sc = SSLContext.getInstance("SSL");
   sc.init(null, trustAllCerts, new java.security.SecureRandom());
   HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
   HttpsURLConnection.setDefaultHostnameVerifier(
       new HostnameVerifier() {
         public boolean verify(String urlHostname, javax.net.ssl.SSLSession _session) {
                                         return true;
         }
       }
    );
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

No spell checker in Visual Web Developer2008

I used to have this feature in Eclipse, so I was disappointed not finding it in Visual Studio 2008 products.

Hands off Craigs List Content

Craigs List is a gem of Bay Array driven by just one man and providing incredible free classified ads. Free means really free, no any paid ads banners, sponsor’s links and so on. Many companies playing in this space tried to put hands on this list offering from $10M to $100M in cash to  the creator. However the list was survived and still free, fast and commonly available. However the list has hard time and has to protect itself from greedy crawlers trying to index it and sell in other places. So what technique the list uses for its protection:

  1. black out lists. All requests are monitored by time interval from the same IP and if interval is less than 1 seconds, the IP gets temporary banned. A work around is simple, do crawling from several Ips keeping requests interval reasonable big coming from the same IP
  2. e-mail addresses scrambling. The list uses HTML encoding for entire e-mail address to prevent SPAM robot from simple retrieving the addresses. A work around is provide HTML decode for sendto: href content
  3. Ad’s text scrambling. The list adds random nothing-meaning HTML tags in content word, like ca<kdlkf>n yo<ff>u stil rea<fgk>d? Obviously browser ignores such tags, but why not crawlers?

Other problem of the list is SPAM robots trying to do mass e-mailing in anonymous or real addresses. Here the list can’t protect much.  Such companies as Goggle provide a good SPAM mailing capabilities against that hard to find a protection. So I’m asking everyone, please do not destroy the list, do not SPAM it and do not index the content. All protection used by the list can be easily bypassed by experienced IT persons like myself, so only way to stop the invasion just think about keeping one good thing on the Earth.

Are computers cheap?

Recently I noticed a small article at MSN claiming that modern computers are cheap. The article gave a comparison of a typical computer of 98 and 08. It can amaze to see that performance/features increased about 100 times when price especially if add inflation rates reduced in 2 times.  However if you think a little, then you can easy understand that computers are no cheap now. Market price of any goods is dictated by demand or other words how much consumers willing to pay. Just imagine if new computer price reflected performance number, who was capable to buy it? Second thing, a computer isn’t a car, or even some other appliance. A refrigerator can last 50 and more years without losing much value. An old car can cost even more than new and still be competitive in performance. But if you take a computer of 98, which can still satisfy you with everyday needs, but you have a problem with software support. My 96 PC is still good, it suitable for filling documents, surfing web, organizing my photos and doing many other things, however I’m pushed to upgrade it, because software vendors want me to pay more to able to use their software. So I’m pushed for upgrading my computer just to be able to use new software. Say more, unless your new software is games, most of other software title may still work perfectly on old hardware. We are forced to upgrade computers every 3-5 years that make computers are not cheap. No other things costing around 1000 require so frequent upgrade. Did I mention that in addition to complete upgrade you have to pay little by little for replacing hard drive, video card, DVD driver and so on between buying a new one. Remember, computers are not cheap.