<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/REC-html40/strict.dtd">
<HTML LANG="en-US">
<head profile="http://dublincore.org/documents/dcq-html/">
<TITLE>Websnob: How To Publish PGP keys on the World Wide Web</TITLE>
<BASE HREF="http://www.websnob.net/keydist">

<META NAME="description" CONTENT="Some observations about distributing PGP
keys through the WWW, and suggested refinements.">
<meta name="DCTERMS.created" scheme="DCTERMS.W3CDTF" content="1996-06-26">

<!--#exec cgi="./cgi/head.pl"-->
</HEAD><BODY>
<p id="breadcrumbs"><a href="/websnob/" rel="Top">Websnob</a> &gt;
<b>Distributing PGP Keys</b></p> 

<p class="advert"><!--#exec cgi="./adverts/ad_1.pl"--></p>

<H1>Publishing <acronym title="Pretty Good Privacy">PGP</acronym> keys on
The Web</H1>

<P>When the Web started becoming popular, one of the reoccuring newbie
questions on <A HREF="news://alt.security.pgp">the newsgroup
alt.security.pgp</A> became:</P>

<BLOCKQUOTE>How do I put my <acronym title="Pretty Good Privacy"><a
href="http://www.openpgp.org/">PGP</a></acronym> key in a web page without
the lines wrapping?</BLOCKQUOTE>

<P>The reoccuring answer, of course, has been:</P>

<BLOCKQUOTE>Place the key between &lt;PRE&gt; and &lt;/PRE&gt;.</BLOCKQUOTE>

<P>Unfortunately, that's a bad answer.  A better (but grumpier) answer
is:</P>

<BLOCKQUOTE>Don't even bother putting the key in an <acronym
title="HyperText Markup Language">HTML</acronym> file. It's an unnecessary
mixing of file types and increases overhead. Put the unadorned keyfile on
the server.</BLOCKQUOTE>

<P>You probably want me to explain that answer. I can do that.</P>

<P>The way I see it, 99% of the people publishing their <acronym
title="Pretty Good Privacy">PGP</acronym> keys on the Web have a hyperlink
on their home page saying &quot;Get my <acronym title="Pretty Good
Privacy">PGP</acronym> key.&quot;, which leads to another <acronym
title="HyperText Markup Language">HTML</acronym> file that
has a <acronym title="Pretty Good Privacy">PGP</acronym> key stuck in the
middle of it. Readers who want to acquire that public key have to save the
file (usually containing blatantly obvious and irritating observations like
&quot;This is my <acronym title="Pretty Good Privacy">PGP</acronym>
key&quot;) and process it outside their browser.</p>

<P>This is bad web design, and a waste of bandwidth. Binary files (Yes,
<acronym title="Pretty Good Privacy">PGP</acronym> keys <EM>are</EM> binary
files, but don't tell your sysadmin, because he might rmgroup <a
href="http://www.alt-security-keydist.info/">alt.security.keydist</a>)
should always be in separate files -- graphics, for example are referenced
using &quot;IMG&quot;, not base64-encoded and jammed in the middle of the
page.</P>

<P>Remember, files accessed via http <EM>aren't</EM> required to be .html
files! (You <EM>have</EM> noticed all those .gif files out there, haven't
you?) Just put the .asc file on your web server and reference it with an
<acronym title="Uniform Resource Locator">URL</acronym> like
<kbd>http://www.example.com/public.asc</kbd> (I use <kbd>public.aexpk</kbd>
instead of <kbd>public.asc</kbd> for my key -- more on that below.) If
users follow <em>that</em> hyperlink, they'll get a file containing the
<acronym title="Pretty Good Privacy">PGP</acronym> key, with no line
wrapping, no <acronym title="HyperText Markup Language">HTML</acronym>, and
no perfunctory gibberish.</P>

<P>Congratulations.  You've just saved a little diskspace and bandwidth,
<EM>and</EM> given yourself some room for more technical improvments. 
Read on.</P>

<H2>An Advanced Approach</h2>

<p>If you're reading this site, you're probably ready to do even better.
Here are three things you can do:</p>

<h3>Use a better file extension</h3>

<p>Some Windows and Macintosh versions of <acronym title="Pretty Good
Privacy">PGP</acronym> associate the <var>.aexpk</var> file extension with
<acronym title="Pretty Good Privacy">PGP</acronym> keys. If you use that
extension for your public key, you make life a little easier for people who
download your key (because you're making sure the key gets assigned a
distinct icon when it appears on their screens), and you make it easier to
configure your web server (because most webservers assign media types based
on file extension -- see below).</p>

<h3>Use the proper media type</h3>

<p>Although you may think your web browser uses file extensions to tell the
difference between <acronym title="HyperText Markup
Language">HTML</acronym> files and everything else, it doesn't. It uses the
"Content-Type" header sent by the web server. If your browser sees a type
it can't process itself, it will either give the file to another program,
or ask you if you want to save the file.</p>

<p>Content-Type headers use the <a
href="http://www.iana.org/assignments/media-types/index.html">Internet
Media Type</a> values originally created for the <acronym title="Multipart
Internet Mail Extensions"><a
href="http://www.oac.uci.edu/indiv/ehood/MIME/MIME.html">MIME</a></acronym>
standard. <a href="http://www.ietf.org/rfc/rfc3156.txt">RFC 3156</a>
defines the media type for ASCII-armored <acronym title="Pretty Good
Privacy">PGP</acronym> keys as "application/pgp-keys". Use that media type
for your .aexpk or .asc files, and you'll make it easier for users to send
your key directly to their <acronym title="Pretty Good
Privacy">PGP</acronym> keyring.</p>

<p>(If <em>you</em> don't declare a media type for <acronym title="Pretty
Good Privacy">PGP</acronym> keys, your webserver will probably default to
"text/plain" (which opens the key in users' browsers), or
"application/octet-stream" (the generic binary type that makes most
browsers ask users if they want to save a file.)</p>

<p>Changing the media type assigned to given file extension is usually a
one-line command in your server configuration file. For instance, an <a
href="http://www.apache.org/">Apache</a> user just has to put this line
in an .htaccess file:</p>

<BLOCKQUOTE><code>AddType application/pgp-keys .aexpk</code></BLOCKQUOTE>

<p>(This is why using .aexpk for keys makes assigned media types easier,
since most webservers limit you to one media type per file extension. Using
.aexpk for keys saves .asc for when you want to publish signed or encrypted
files.)</p>

<h3>Use better <acronym title="HyperText Markup Language">HTML</acronym></h3>

<p>Even if you're using the "application/pgp-keys" media type, you can link
to your key like any other web page. It would be good manners, however, to
include a <samp>type</samp> attribute in the link's markup. For example:</p>

<blockquote><code>&lt;a href="public.aexpk"
type="application/pgp-keys"&gt;public.aexpk&lt;/a&gt;</code></blockquote>

<p>The <samp>type</samp> attribute doesn't really change how browsers
handle the link, but it lets users who care about these things check the
link's content type before they click on it. (For example, <a
href="http://www.mozilla.org/">Mozilla</a> will display the media type in a
"Properties" box.)</p>

<h2>Demonstration</h2>

<p>Here's a <a href= "http://www.michael.bauser.name/bin/public.aexpk"
type="application/pgp-keys">link to my public key</a> that uses all of the
steps described above. If you want, click on it and see what happens.</p>

<p>If your web browser doesn't know what to do with the media type, take
the opportunity to assign it to <acronym title="Pretty Good
Privacy">PGP</acronym>. (If you're using a version of <acronym
title="Pretty Good Privacy">PGP</acronym> that has a separate key-managing
utility like <var>PGPKEYS.EXE</var>, use that instead of the <acronym
title="Pretty Good Privacy">PGP</acronym> executable.)</p>

<h2>Historical Notes</h2>

<p>The original 1996 version of this article recommended using "Content-Type:
application/pgp". That was before <a href=
"http://www.ietf.org/rfc/rfc2015.txt" title="RFC 2015: MIME Security with
Pretty Good Privacy (PGP)" >RFC 2015</a> officially defined the
"application/pgp-keys" media type.</p>

<p>Some versions of this page also recommended distributing keys in binary
format. That recommendation was rescinded when <a
href="http://www.ietf.org/rfc/rfc3156.txt" title="RFC 3156: MIME Security
with OpenPGP">RFC 3156</a> updated the <acronym title="Pretty Good
Privacy">PGP</acronym>/<acronym title="Multipart Internet Mail
Extensions">MIME</acronym> standard to explicitly limit
"application/pgp-keys" to ASCII-armored files. Binary public keys must
instead be assigned the "application/octet-stream" media type, and may use
the <var>.bexpk</var> file extension to differentiate them from
ASCII-armored keys.</p>

<p>It only took <em>eight years</em>, but <a href=
"http://philringnalda.com/blog/2004/02/links_rels_and_profiles.php" >other
people</a> figured out how to distribute PGP keys in a proper format! (I'm
not too thrilled about how he uses the <samp>link</samp> element,
though.)</p>
 
<h2>A Final Disclaimer</h2>

<p>I should probably confess: I <em>did</em> have &quot;a <acronym
title="Pretty Good Privacy">PGP</acronym> key stuck in the middle&quot; of
<a href= "http://slashdot.org/~mbauser2" >my Slashdot user profile</a> and
<a href= "http://people.whowhere.lycos.com/pages/mbauser2" >my WhoWhere.com
directory listing</A>, because that's the only option they provided for
distributing encryption keys. So if you're faced with a similar choice,
don't feel too bad about it. I understand.</p>

<p class="advert"><!--#exec cgi="./adverts/ad_2.pl"--></p>
<!--#exec cgi="./cgi/menu.pl"-->
<!--#exec cgi="./cgi/1996"-->
</BODY></HTML>


