2016-05-31 17:07:33 -05:00
|
|
|
#!/usr/bin/python2
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2017-08-22 20:22:48 -05:00
|
|
|
import traceback
|
2016-05-31 17:07:33 -05:00
|
|
|
|
|
|
|
from ipalib import constants
|
|
|
|
from ipalib.config import Env
|
|
|
|
from ipaplatform.paths import paths
|
2016-11-22 10:55:10 -06:00
|
|
|
from ipaserver.secrets.client import CustodiaClient
|
2016-05-31 17:07:33 -05:00
|
|
|
|
|
|
|
|
2017-08-22 20:22:48 -05:00
|
|
|
def main():
|
|
|
|
env = Env()
|
|
|
|
env._finalize()
|
2016-05-31 17:07:33 -05:00
|
|
|
|
2017-08-22 20:22:48 -05:00
|
|
|
keyname = "ca_wrapped/" + sys.argv[1]
|
|
|
|
servername = sys.argv[2]
|
2016-05-31 17:07:33 -05:00
|
|
|
|
2017-08-22 20:22:48 -05:00
|
|
|
service = constants.PKI_GSSAPI_SERVICE_NAME
|
|
|
|
client_keyfile = os.path.join(paths.PKI_TOMCAT, service + '.keys')
|
|
|
|
client_keytab = os.path.join(paths.PKI_TOMCAT, service + '.keytab')
|
2016-05-31 17:07:33 -05:00
|
|
|
|
2017-08-22 20:22:48 -05:00
|
|
|
# pylint: disable=no-member
|
|
|
|
client = CustodiaClient(
|
|
|
|
client_service='%s@%s' % (service, env.host), server=servername,
|
|
|
|
realm=env.realm, ldap_uri="ldaps://" + env.host,
|
|
|
|
keyfile=client_keyfile, keytab=client_keytab,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Print the response JSON to stdout; it is already in the format
|
|
|
|
# that Dogtag's ExternalProcessKeyRetriever expects
|
|
|
|
print(client.fetch_key(keyname, store=False))
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
main()
|
|
|
|
except BaseException:
|
|
|
|
traceback.print_exc()
|
|
|
|
sys.exit(1)
|