Skip to content

Instantly share code, notes, and snippets.

@frederickding
Last active May 11, 2024 21:42
Show Gist options
  • Save frederickding/6c614b8d473988dd7475383a1acaf6f3 to your computer and use it in GitHub Desktop.
Save frederickding/6c614b8d473988dd7475383a1acaf6f3 to your computer and use it in GitHub Desktop.
Apache fancyindex for PKI files
<!DOCTYPE html>
<html>
<head>
<title>Index of /pki</title>
<style type="text/css">
body {
font-family: Georgia, Century, serif;
}
table {
border-spacing: 4px;
}
td {
font-family: monospace;
padding-left: 1em;
padding-right: 1em;
}
table tr th:nth-child(4), table tr td:nth-child(4) {
visibility: hidden;
}
table tr td:first-child {
width: 20em;
}
table tr td {
min-width: 6em;
}
</style>
</head>
<h1>Index of /pki</h1>
Header set Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate"
Header set Pragma "no-cache"
IndexOptions FancyIndexing SuppressHTMLPreamble HTMLTable -SuppressDescription SuppressIcon SuppressColumnSorting
HeaderName .header.html
ReadmeName .footer.html
RewriteEngine On
RewriteRule "(.*\.crt)\.txt" "$1?txt" [QSD]
RewriteRule "(.*).pem" "$1.crt?txt" [QSD]
RewriteCond "%{QUERY_STRING}" "txt"
RewriteRule ".?" "-" [T=text/plain,L]
@frederickding
Copy link
Author

frederickding commented May 11, 2024

This is some Apache configuration so that when root/intermediate certification authority files are stored as base64-encoded PEM files with the extension .crt (which Windows likes), the same file will also be available as .pem and .txt files. Additionally, those .pem and .txt options are served as plain text (which is useful for pasting from a browser into a terminal or other UI).

mod_rewrite and mod_autoindex are needed.

Screenshot

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment