Skip to content

Instantly share code, notes, and snippets.

@rhulha
Created September 18, 2018 13:48
Show Gist options
  • Save rhulha/1856d704d79208fdeff65c9f88dd5d56 to your computer and use it in GitHub Desktop.
Save rhulha/1856d704d79208fdeff65c9f88dd5d56 to your computer and use it in GitHub Desktop.
Create a Sophos UTM9 emailpki user
class Config:
REST_BASE_URL = "https://myip:4444/api/"
AUTH=('token', 'mytoken')
import requests
PGP= {
"comment": "",
"emails": [
"[email protected]"
],
"expires": "",
"fingerprint": "BC6A711399F7FF6EE4E76BCC39DEC7E2CF24C7D6",
"name": "BC6A711399F7FF6EE4E76BCC39DEC7E2CF24C7D6",
"privkey": "lQNLBFufTRARCADjT17uqsDiYUzssiJuPW1+MhwZjbVjZXFZzY44xFlog6um2q56FKI7kL9Ci+zG\n9DciNEKvSrSR/YYE/YYkc84o7miFc1K/+GKe5gj023EoHHKD7puWjMKV3FZXwhaXWY25xw/BZNYc\nTVKKKA6z0GdYGp+9Wd4aZPCkYSEI42NM2r9aczz3HnjNciPitxBnbpF6d62yIxarFLQD3232pagT\noGcPrw26zGrk6Nis4rQqH3u0hD3R1l8Rcd2tMa/GJgcFxGnXPFX8KR3sPwtgJpp1zPKjdID+n7GK\nqZy1OUNMILZ33FYCcaYS8iQV24ve4tRm8Q1+t8cA4Y14I/dfbmUnAOC3bBVLXNtQs3r3tt83qvVm\npDSsGfp9luHL4Y1lCACu5W5TpXCcF3uqHz09Ac8In40JPIK/OLuvwVdMe2QKKDuPOMkXDwULn5Vn\npmz5Ndrj2sg/Zd6prlhE2Ga97rtr9F/6GJGLpZaIYtG6uiFh1m3P7jAS6bOAkTYYc6+ptXoODHi/\nCj5iL0lcNw6xGHGsygiAPETG7UCX01oegzoloc0U4RK2kYZIkNvvNqQZwmEF0k5nZZajiU1tzLmn\niJJjvCQ3Z2hbmbMEJh8ac7dK3XBnqu3w2VBoLzMHIBgL+LVekS8G/Ru+Ean78ftlt8GnbV8mRkiG\nkURg+F0p7mdVfElVzf/fXmSS+r0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qhy7/bxnf4V\nhuoHwaJ0G3kCG3VJPPsXxO5+yCwB1uYUSGEGtcVGoJ8q73LbWGQgXkNC44tl6+Sb\nQgIUZOg2JLeLzCAYBW5JvmFKyih0FaQjJyHkJu2hB32eupcniwFU4p3nZUXPqgAh\ngVKcpCU2EDi9i9+VMbonqQIfmbbApyCGcd0lKWiWb5cANthFHJc9s4xxo4UHtfY4\nN0lMpnVekniXC2J/Eh48h172PAJL7+03l4eQvoB/3uGOH2qhHPMxNGOOyw6uiXQK\nANdJBnLHE/XRAgMBAAGjgacwgaQwCQYDVR0TBAIwADARBglghkgBhvhCAQEEBAMC\nBLAwLAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRl\nMB0GA1UdDgQWBBQw9FBdwTF5ILOvnlVCDEEYY1cUNTAfBgNVHSMEGDAWgBQ/P4E3\njG8dQw5OrdJG5KXWF7YeWDAWBgNVHREEDzANgQt0b21AdGVzdC5kZTANBgkqhkiG\n9w0BAQ0FAAOCAQEAWxpvD60vEXsnjg3/oAa5f1AYLXa6GpaGm5GKegtL12exDeD5\n0mJmxWM7AruHCYPR7QdRDBLQUOh51/Bo+q5eNebo0zsgqYR1hklmxGAQz/bLm+3e\njIIPjpRls+6o2Xkm0QUXaP42zOMJDYi3TtP5eJRGJoZRj1nWnyoXDiIJlfBzZf1B\nEpgTh0vrkEPcRr76RC1ZyYjpuTt3mIv5ZKvMB/1/CB8P6h1iIqOX6cZxpD/vOgyh\n7SGm16zpxtlPDjeGmNx8OlNiQVddqgWqidwv46RPJPa61CGRJ8Sr4UQV71R54SPf\ni/a4x8hYDOrbbgpM7F8kGkU4w7SIQunOfGCwkA==\n-----END CERTIFICATE-----\n",
"comment": "",
"dn": "C=de, O=TEST, OU=Gateway, CN=Tom Sawyer, [email protected]",
"domaincert": False,
"emails": [
"[email protected]"
],
"expires": "Sep 12 06:43:38 2038 GMT",
"fingerprint": "FFFE79A4321F88FD08760AAE8E25E3E0C8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mMN6u3MT6TpxPATHBCd2WQ9z7ug0O4KMs5PGNmuvdGYKKY4xDFxsY+FnhKfXI3E\n+tkDj/BzAQKBgQCxiC2BsvFbz1G+DB11vZR3Ou5cLqQly0mYDIywMm1NZtRPL7bM\nZF0RUbcElKOFLhv56gd1oMzM43eUi2gzd9a80qQqlV7MvNTFqnolzk4qHF8+tLLb\n2cb7bTk8TelED4agYnkl8pyEhNZqYwZg1uxq2smK50jcM/CNWHOulv4lkQKBgQCp\n5WBNOO3J+f1N5HZNjl8dBHCz4CS/MONKbYY+hu/WEF0wt9fhAi08Bcv6DZG+BI3s\nffg1ZyKrggiWXwGdA9vROhWWkqWigpjMHcNNWR+o1akcG30148KEHGI7L/vM25TB\nn36S3N2Ekvm+ANMqKdokaFED88Ev7NBodi25++AzAQKBgQDYlTuX7bxqjpcnMFWa\nS+aNSy0tXCGJQUeWUoh5YNaT/1wWaoszEQAOVYriZNo2jG3N9PBN04bSHsyypTYV\n60+bKpTWvcBDrtHiM+5N6Von4iJTKfrZREqLNUXKReV8hUU9ihRGdvX7vKEHv0Hc\nT1UEiHz7bPlw7aWuH7fVFoYtFw==\n-----END PRIVATE KEY-----\n",
"name": "FFFE79A4321F88FD08760AAE8E25E3E0C8CA51DA",
"realname": "",
"trust": True
}
User= {
"comment": "",
"decrypt": "global",
"domaincert": False,
"encrypt": "global",
"name": "[email protected]",
"openpgp": "REF_EmaOpeBc6a711399",
"openpgp_status": True,
"realname": "Tom Sawyer",
"sign": "global",
"smime": "REF_EmaSmiFffe79a432",
"smime_status": True,
"verify": "global"
}
response = requests.post(Config.REST_BASE_URL + 'objects/emailpki/openpgp/', json=PGP, auth=Config.AUTH, verify=False)
print (response.status_code)
print (response.text)
response = requests.post(Config.REST_BASE_URL + 'objects/emailpki/smime/', json=SMIME, auth=Config.AUTH, verify=False)
print (response.status_code)
print (response.text)
response = requests.post(Config.REST_BASE_URL + 'objects/emailpki/user/', json=User, auth=Config.AUTH, verify=False)
print (response.status_code)
print (response.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment