How to get the RHEL binary using the provided XMLRPC library - HTTP Response '401 Authorization Required'

Posted on

Hi,

I'm trying to get the rpm binary on my subscribed RHEL-6-Server machine using the XMLRPC calls to the URL "https://xmlrpc.rhn.redhat.com/XMLRPC".

I did the following :

  • Generated the systemid file after running the command
rhn_register
  • Using the up2date.login call, I logged-in using my rhn account (/etc/sysconfig/rhn/systemid file).
The corresponding HTTP Request-Response exchange is :

 --- request ---

POST https://xmlrpc.rhn.redhat.com/XMLRPC
Content-Type: application/json
<?xml version="1.0"?>
<methodCall>
    <methodName>up2date.login</methodName>
    <params>
        <param>
            <value>
                <string> ****  System ID File Content  **** </string>
            </value>
        </param>
    </params>
</methodCall>


 -- response --

200 OK
Date:  Tue, 23 Jun 2015 06:30:39 GMT
Server:  Apache
Content-Language:  en; C
Content-Length:  903
X-RHN-Server-Capability:  registration.finish_message(1)=1, registration.remaining_subscriptions(1)=1, applet.has_base_channel(1)=1, registration.smbios(1)=1, registration.extended_update_support(1)=1, rhncfg.filetype.directory(1)=1, rhncfg.content.base64_decode(1)=1, registration.register_osad(1)=1, registration.delta_packages(1)=1, xmlrpc.packages.extended_profile(1)=1, xmlrpc.packages.checksums(1)=1, xmlrpc.login.extra_data(1)=1
X-RHN-Server-Id:  1000010000
X-RHN-Proxy-Version:  0
X-RHN-Auth-Server-Time:  1435041039.43
X-RHN-Client-Version:  0
X-Transport-Info:  Extended Capabilities Transport (C) Red Hat, Inc (version $Revision$)
X-RHN-Auth-Channels:  rhel-x86_64-server-6:20150622101926:1:1
X-RHN-Action:  login
X-RHN-Auth:  ***  Hidden Contents  ***
X-RHN-Auth-Expire-Offset:  3600.0
Content-Type:  text/xml
X-Cache:  MISS from web-server
X-Cache-Lookup:  MISS from web-server:3128
Proxy-Connection:  keep-alive

<?xml version="1.0"?>
<methodResponse>
    <params>
        <param>
            <value>
                <struct>
                    <member>
                        <name>X-RHN-Server-Id</name>
                        <value>
                            <int>1000010000</int>
                        </value>
                    </member>
                    <member>
                        <name>X-RHN-Auth-Server-Time</name>
                        <value>
                            <string>1435041039.43</string>
                        </value>
                    </member>
                    <member>
                        <name>X-RHN-Auth-Channels</name>
                        <value>
                            <array>
                                <data>
                                    <value>
                                        <array>
                                            <data>
                                                <value>
                                                    <string>rhel-x86_64-server-6</string>
                                                </value>
                                                <value>
                                                    <string>20150622101926</string>
                                                </value>
                                                <value>
                                                    <string>1</string>
                                                </value>
                                                <value>
                                                    <string>1</string>
                                                </value>
                                            </data>
                                        </array>
                                    </value>
                                </data>
                            </array>
                        </value>
                    </member>
                    <member>
                        <name>X-RHN-Auth</name>
                        <value>
                            <string>rc+<-Hidden Contents->Q==</string>
                        </value>
                    </member>
                    <member>
                        <name>X-RHN-Auth-User-Id</name>
                        <value>
                            <string/>
                        </value>
                    </member>
                    <member>
                        <name>X-RHN-Auth-Expire-Offset</name>
                        <value>
                            <string>3600.0</string>
                        </value>
                    </member>
                </struct>
            </value>
        </param>
    </params>
</methodResponse>
  • With these attained credentials, am attempting to list all the packages for that channel. But, it gives a 401 Authorization Required HTTP Response.
The corresponding exchange is as follows :

 --- request ---

GET https://xmlrpc.rhn.redhat.com/XMLRPC/$RHN/rhel-x86_64-server-6/listPackages
X-RHN-Client-Version: 2
X-RHN-Server-Id: 1000010000
X-RHN-Auth-Server-Time: 1435041039.43
X-RHN-Auth: rc+<-Hidden Contents->Q==
X-RHN-Auth-User-Id: 
X-RHN-Auth-Channels: [['rhel-x86_64-server-6', '20150622101926', '1', '1']]
X-RHN-Auth-Expire-Offset: 3600.0


 -- response --

401 Unauthorized
Date:  Tue, 23 Jun 2015 07:17:03 GMT
Server:  Apache
X-RHN-Fault-Code:  -33
X-RHN-Fault-String:  CkVycm9yIE1lc3NhZ2U6CiAgICBJbnZhbGlkIGNsaWVudCBzZXNzaW9uIGtleQpFcnJvciBDbGFz, cyBDb2RlOiAzMwpFcnJvciBDbGFzcyBJbmZvOiBDbGllbnQgc2Vzc2lvbiB0b2tlbiBpcyBpbnZh, bGlkLgpFeHBsYW5hdGlvbjogCiAgICAgQW4gZXJyb3IgaGFzIG9jY3VycmVkIHdoaWxlIHByb2Nl, c3NpbmcgeW91ciByZXF1ZXN0LiBJZiB0aGlzIHByb2JsZW0KICAgICBwZXJzaXN0cyBwbGVhc2Ug, ZW50ZXIgYSBidWcgcmVwb3J0IGF0IGJ1Z3ppbGxhLnJlZGhhdC5jb20uCiAgICAgSWYgeW91IGNo, b29zZSB0byBzdWJtaXQgdGhlIGJ1ZyByZXBvcnQsIHBsZWFzZSBiZSBzdXJlIHRvIGluY2x1ZGUK, ICAgICBkZXRhaWxzIG9mIHdoYXQgeW91IHdlcmUgdHJ5aW5nIHRvIGRvIHdoZW4gdGhpcyBlcnJv, ciBvY2N1cnJlZCBhbmQKICAgICBkZXRhaWxzIG9uIGhvdyB0byByZXByb2R1Y2UgdGhpcyBwcm9i, bGVtLgo=
X-RHN-Proxy-Version:  0
X-RHN-Client-Version:  2
Content-Length:  472
Content-Type:  text/html; charset=iso-8859-1
X-Cache:  MISS from web-server
X-Cache-Lookup:  MISS from web-server:3128
Proxy-Connection:  keep-alive

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
   <head>
      <title>401 Authorization Required</title>
   </head>
   <body>
      <h1>Authorization Required</h1>
      <p>This server could not verify that you
         are authorized to access the document
         requested.  Either you supplied the wrong
         credentials (e.g., bad password), or your
         browser doesn't understand how to supply
         the credentials required.
      </p>
      <hr>
      <address>Apache Server at xmlrpc.rhn.redhat.com Port 80</address>
   </body>
</html>

This error is thrown for the HTTP GET Requests to the following URLs :
https://xmlrpc.rhn.redhat.com/XMLRPC/$RHN/rhel-x86_64-server-6/getPackageHeader/avahi-0.6.25-15.el6.x86_64.rpm
https://xmlrpc.rhn.redhat.com/XMLRPC/$RHN/rhel-x86_64-server-6/getPackage/avahi-0.6.25-15.el6.x86_64.rpm

Am I missing something? Can someone please help me out?

Also, share any documentation regarding the APIs used.
(Could not relate to the only document I could find : Red_Hat_Network 5.0.0 API_Documentation)

Thanks & Regards,
Rangaraj

Responses