Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepython
#!/usr/bin/python
import urllib
import httplib
import M2Crypto
import time
import simplejson
import base64
request_id = 3930
ctx = M2Crypto.SSL.Context()
ctx.load_cert("/home/hayashis/.globus/soichi.2014.pem")
headers = {'Content-type': "application/x-www-form-urlencoded", 'User-Agent': 'OIMGridAPIClient/0.1 (OIM Grid API)'}
print "renewing"
conn #conn = M2Crypto.httpslib.HTTPSConnection("oim-itb.grid.iu.edu", ssl_context=ctx)
conn = httplib.HTTPConnection("oim-itb.grid.iu.edu:80")
conn.set_debuglevel(1)
params = urllib.urlencode({'host_request_id': request_id}, doseq=True)
conn.request('POST', "/oim/rest?action=host_certs_retrieve", params, headers)
ssl_session = conn.get_session()
response = conn.getresponse()
data = simplejson.loads(response.read())
cookie = response.getheader("set-cookie")
#debug
#printprint response.status, response.reason
#printprint data
idx=0
for pkcs7 in data["pkcs7s"]:
    name = "/tmp/hostcert.%d.%d.pem" % (request_id, idx)
    print name
    f = open(name, "w")
    f.write(pkcs7)
    f.close()
    idx+=1
-
conn.close()