Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created January 28, 2016 12:25
Show Gist options
  • Select an option

  • Save ableasdale/8180ee02c0df28123cb7 to your computer and use it in GitHub Desktop.

Select an option

Save ableasdale/8180ee02c0df28123cb7 to your computer and use it in GitHub Desktop.
Associate an installed certificate with a MarkLogic Application Server
xquery version "1.0-ml";
import module namespace pki = "http://marklogic.com/xdmp/pki" at "/MarkLogic/pki.xqy";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
declare namespace x509 = "http://marklogic.com/xdmp/x509";
let $config := admin:get-configuration()
let $groupid := admin:group-get-id($config, "Default")
let $appservid := admin:appserver-get-id($config, $groupid, "DemoAppServer")
let $cert-id := for $cert in pki:get-certificates(pki:get-trusted-certificate-ids())
where $cert/x509:cert/x509:subject/x509:commonName eq "DemoLab CA"
return fn:data($cert/pki:certificate-id)
let $spec := admin:appserver-set-ssl-client-certificate-authorities($config, $appservid, $cert-id)
return admin:save-configuration($spec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment