It’s been a while since I wrote my last blog post. The major update since then is that I have been accepted as an Outreachy Intern. Yaaay!! 😀
I am doing my internship with OpenStack, specifically I am working on Glance under my mentor Nikhil Komawar. The project that I had proposed as part of my application was “Migrating Glance replicator to requests for HTTPS support”.
Currently, glance replicator uses the httplib library, and thus does not support the proper verification of HTTPS connections. I am working on rewriting the code to switch to using requests library instead which will allow the automatic verification of all HTTPS connections. Also, since an operator may want to sign their own custom certificates, I am also working on adding a command-line option to specify a custom certification bundle to be used when verifying the server certificate.
I have already finished major refactoring of the code to shift to using the requests library. To do this, I first had to make changes in how the connections were being established (as they were using httplib earlier). Also, how the response from the server was handled had to be modified a bit in accordance with the requests library.
I have also added the command line option for specifying a custom certification bundle. It turned out to be a pretty straightforward task since requests has an optional argument that can be specified to use custom certificates when establishing a connection.
The changes I made involved learning some things about the requests library. The first thing that I learned was about the Session object. A session object allows you to reuse certain parameters across requests. So if you’re making a lot of connections to the same host, it will allow you to reuse the same TCP connection. Another concept that was new to me in the requests library was that of Transport Adapters. Transport Adapters basically allow you to define specific interactive methods for a HTTP service i.e. they provide the option to configure the different HTTP services. Users can create their own transport adapters to provide any specific functionality. Once you create the Transport Adapter, you can mount it to a session object and also specify which service(s) is to use that particular adapter. Once the transport adapter has been mounted to the session, any request that is made using that session which has the prefix mentioned for that specific adapter will then use that specific transport adapter.
That’s all for now! Thanks for reading! 🙂