How to use HTML5 “keygen” Tag

HTML <keygen> Tag

The HTML <keygen> element exists to facilitate generation of key material, and submission of the public key as part of an HTML form. This mechanism is designed for use with Web-based certificate management systems. It is expected that the <keygen> element will be used in an HTML form along with other information needed to construct a certificate request, and that the result of the process will be a signed certificate.

Example

A form with a keygen field:

<html>

<body>

<form action=”floatingwebs.php” method=”get”>

Username: <input type=”text” name=”usr_name”>

Encryption: <keygen name=”security”>

<input type=”submit”>

</form>

<p><strong>Note:</strong> The keygen tag is not supported in Internet Explorer.</p>

</body>

</html>

Attributes

This element includes the global attributes.

autofocus

This Boolean attribute lets you specify that the control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only one form element in a document can have the autofocus attribute, which is a Boolean

Example

<form action=”floatingwebs.php” method=”get”>
Username: <input type=”text” name=”usr_name”>
Encryption: <keygen name=”security” autofocus>
<input type=”submit”>
</form>

challenge

A challenge string that is submitted along with the public key. Defaults to an empty string if not specified.

disabled

This Boolean attribute indicates that the form control is not available for interaction.

Example

<form action=”floatingwebs.php” method=”get”>
Username: <input type=”text” name=”usr_name”>
Encryption: <keygen name=”security” disabled>
<input type=”submit”>
</form>

form

The form element that this element is associated with (its form owner). The value of the attribute must be an id of a <form> element in the same document. If this attribute is not specified, this element must be a descendant of a <form> element. This attribute enables you to place <keygen> elements anywhere within a document, not just as descendants of their form elements.

Example

<form action=”floatingwebs.php” method=”get” id=”secureform”>
Username: <input type=”text” name=”usr_name”>
<input type=”submit”>
</form>
Encryption: <keygen name=”security” form=”secureform”>

keytype

The type of key generated. The default value is RSA.

Example

<form action=”floatingwebs.php” method=”get”>
Username: <input type=”text” name=”usr_name”>
Encryption: <keygen name=”security” keytype=”rsa”>
<input type=”submit”>
</form>

name

The name of the control, which is submitted with the form data.

Example

<form action=”floatingwebs.php” method=”get”>
Username: <input type=”text” name=”usr_name”>
Encryption: <keygen name=”security”>
<input type=”submit”>
</form>

Differences Between HTML 4.01 and HTML5

The <keygen> element is new in HTML5.

 

Leave a Reply

Your email address will not be published. Required fields are marked *