Ruby XMLRPC over a Self Certified SSL with a warning

If you use the XMLRPC client in ruby over a self certified SSL you have this warning :

warning: peer certificate won’t be verified in this SSL session

You can get override that warning cleanly (i have seen some people who just comment the message in the standard library) like that :

require 'xmlrpc/client'

require 'net/https'
require 'openssl'
require 'pp'

module SELF_SSL
  class Net_HTTP < Net::HTTP
    def initialize(*args)
      super
      @ssl_context = OpenSSL::SSL::SSLContext.new
      @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
    end
  end

  class XMLRPC_Client < XMLRPC::Client
    def initialize(*args)
      super
      @http = SELF_SSL::Net_HTTP.new( @host, @port,
                                      @proxy_host,@proxy_port )
      @http.use_ssl = @use_ssl if @use_ssl
      @http.read_timeout = @timeout
      @http.open_timeout = @timeout
    end

  end

end

if __FILE__ == $0
  f = SELF_SSL::XMLRPC_Client.new2("https://url")
  puts f.call("method", 'arg')
end

Yum Force Exclude List

While talking with my fellow colleague Darren Birkett about what seems a design limitation
of yum to not be able to force listing the excludes from yum. I had a
shoot to make a yum plugin to force listing the excludes.

Here is how it works :

root@centos5:~> grep exclude /etc/yum.conf
exclude=rpm*
root@centos5:~> yum install rpm-devel
Loading “installonlyn” plugin
Loading “changelog” plugin
Loading “chmouel” plugin
Loading “priorities” plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Excluding Packages in global exclude list
Finished
0 packages excluded due to repository priority protections
Parsing package install arguments
Nothing to do

rpm* is excluded, but if we use the environment variable FORCE_EXCLUDE
it will force it.

 root@centos5:~> FORCE_EXCLUDE=true yum install rpm-devel
Loading “installonlyn” plugin
Loading “changelog” plugin
Loading “chmouel” plugin
Loading “priorities” plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
0 packages excluded due to repository priority protections
Parsing package install arguments
Resolving Dependencies
–> Populating transaction set with selected packages. Please wait.
—> Downloading header for rpm-devel to pack into transaction set.
rpm-devel-4.4.2-47.el5.i3 100% |=========================| 17 kB 00:00
—> Package rpm-devel.i386 0:4.4.2-47.el5 set to be updated
–> Running transaction check
[…..]

It will allow you to list the excluded rpm as well :

 root@centos5:~> FORCE_EXCLUDE=true yum list|grep rpm
rpm.i386 4.4.2-47.el5 installed
rpm-libs.i386 4.4.2-47.el5 installed
rpm-python.i386 4.4.2-47.el5 installed
redhat-rpm-config.noarch 8.0.45-22.el5.centos base
rpm-build.i386 4.4.2-47.el5 base
rpm-devel.i386 4.4.2-47.el5 base
root@centos5:~> yum list|grep rpm
rpm.i386 4.4.2-47.el5 installed
rpm-libs.i386 4.4.2-47.el5 installed
rpm-python.i386 4.4.2-47.el5 installed
redhat-rpm-config.noarch 8.0.45-22.el5.centos base

See the README.txt in the rpm file to see how to use/install it.

You can download the rpm here and the src.rpm here