Loading TOC...

MarkLogic 10 Product Documentation
pki:get-certificate-pem

pki:get-certificate-pem(
   $template-id as xs:unsignedLong,
   $hostname as xs:string
) as xs:string*

Summary

This function returns the PEM encoded certificate for the specified certificate template and common name combination.

Parameters
template-id The certificate template id for the certificate to be returned.
hostname The common host name, if any.

Example

    (: execute this against the security database :)
    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";
 
    let $config := admin:get-configuration()
    let $tid := pki:template-get-id(pki:get-template-by-name("mycert"))
    let $hostname := admin:host-get-name(
                       $config, 
                       admin:host-get-id($config, xdmp:host-name()))

    return pki:get-certificate-pem($tid, $hostname) 
  
  =>
      -----BEGIN CERTIFICATE-----
      MIICbzCCAdigAwIBAgIEL9pBCTANBgkqhkiG9w0BAQUFADBrMQswCQYDVQQGEwJV
      UzELMAkGA1UECBMCQ0ExEzARBgNVBAcTClNhbiBDYXJsb3MxEzARBgNVBAoTCk1h
      cmsgTG9naWMxJTAjBgNVBAMTHGhwNjkxMC02MjR2NjRiLm1hcmtsb2dpYy5jb20w
      HhcNMDkwMjE4MjAxOTA4WhcNMTAwMjE4MjAxOTA4WjBrMQswCQYDVQQGEwJVUzEL
      MAkGA1UECBMCQ0ExEzARBgNVBAcTClNhbiBDYXJsb3MxEzARBgNVBAoTCk1hcmsg
      TG9naWMxJTAjBgNVBAMTHGhwNjkxMC02MjR2NjRiLm1hcmtsb2dpYy5jb20wgZ8w
      DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM/gj+cfWnL2IOsUgbiKhEahbdbCye57
      NcschJ0mMzBaHcJ43u/HhJI11RhW9rCUaF9h8JAMmtP03TFEkFzaUs9NZNTqvVzH
      mWjk71oKvy/JJUley15Lbs/twqmDo6punvsWFbjxKt6kzjrg6NMNTxn2pGOtYEf6
      yymUfL19J069AgMBAAGjIDAeMAkGA1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQDAgZA
      MA0GCSqGSIb3DQEBBQUAA4GBAJvN5UVn/b6S2XUYge9aQDiIhyc1EwbWyuXxvA6i
      WCiTWUl/2Dbh+UNjK+KwLvxO8wR4RLO4TtX86XA0Up+3fpLDyY+Q3W0Q2uj6ZzMe
      pRmQyo67qQDrfJU8bgUzx0uqTEbgYhGyJ3IQuNpUWt9tZty6+4i6WdCgGVA9CWuU
      ujPm
      -----END CERTIFICATE-----
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.