Last active
September 21, 2018 09:09
-
-
Save derms/cc93ece22379e86a0933282ba1aacbeb to your computer and use it in GitHub Desktop.
MarkLogic certificate scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
let pki = require("/MarkLogic/pki.xqy") | |
let host = "my.host.com" | |
let id = pki.getCertificates(pki.getTrustedCertificateIds()).toArray() | |
.filter(c=>String(fn.head(c.xpath("//*:host-name/text()")))==host) | |
.map(c=>fn.head(c.xpath("//*:certificate-id/text()")))[0] | |
if (id) { | |
pki.deleteCertificate(id) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
let key = `pem encoded private key` | |
let cert = `pem encoded cert` | |
let pki = require("/MarkLogic/pki.xqy") | |
pki.insertHostCertificate( | |
pki.templateGetId(pki.getTemplateByName("MyTemplate")), | |
cert, | |
key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment