Bouncy Castle - Extended Key Usage

2013-03-23 13:13:35 +0000

If you look at a certificate, you will see something like one of the following:

This certificate is intended for the following purpose(s):

There are two ways to specify these purposes: you can use the “key usage” extension, which is specified in section of RFC 5820, or you can use the “extended key usage” extension, which is specified in section The extended key usage extension is more flexible.

To specify that a certificate can be used for “server authentication”, we can use the following code:

// Add the "Extended Key Usage" attribute, specifying "server authentication".
var usages = new[] { KeyPurposeID.IdKPServerAuth };
	new ExtendedKeyUsage(usages));

In the next post, I’ll discuss “subject alternative names”, and then I’ll show how to create CA certificates and how to use those to issue server and client certificates. Then I think that’s about it for this series of posts.