PKI for ImplementorsSo, you'd like to start using X.509 certificates in your application. And you'd like to "do it right". Well, this guide is intended to help you do that. We're writing this guide because we've found that PKI tutorials tend to fall into one of two categories. Either they focus on a how a given library or application implements some PKI features, or they explain PKI from a high-level concepts view. Some familiarity with these high-level concepts will be assumed from here on in, so if you aren't sure what a Registration Authority, a Certification Authority, or non-repudiation is, or if you aren't sure of the basics of digital signature, then you may want to take a minute to read the guides that we've written on these topics. For basic information, our Fingerpuppet PKI Tutorials will give you a good start. We've also written a more in-depth PKI guide as well. All right, now that everyone has all the basic concepts, let's get into what an implementor needs to know. Broadly, they can be summed up as follows:
What are the consequences of mis-identifying either the client or the server? If you don't really care about the identities of the parties in a communication, and all you want to do is encrypt things, then you can save yourself a lot of effort and implement a simple shared secret scheme. Unfortunately, if you are stuck using SSL (or TLS as it is now called), then at least the server side of your service needs a certificate, but it can be a self-signed certificate that provides no identity assurance, as long as both ends of the communication turn off any certificate validity checking. If you are working with web clients (i.e.: web browsers such as Internet Explorer and Mozilla Firefox), then save yourself a lot of problems, and just buy your server certificate from a commercial Certificate Authority. If you DO care about the identities of the two parties that are communicating, then you are using the right technology. PKI is very well suited to helping two parties confirm their identities. You do still need to ask yourself what is the real danger of accepting an identity that you shouldn't, since that will directly influence the complexity of what you need to do to make sure that all identities are confirmed correctly. How are the identities you need expressed in the certificate Certificate #1: Subject: C=CA, O=Carillon Information Security Inc., OU=Technical Services, CN=Alice Smith (Identity) Certificate #2: Subject: C=DE, O=Very Large Company, OU=Business Unit Name, serialNumber=123456789, CN=Alice Smith Certificate #3: Subject: C=DE, O=Very Large Company, OU=Business Unit Name, serialNumber=456789012, CN=Alice Smith Certificate #4: Subject: DC=com, DC=example, O=Example Widget Company, CN=Alice Smith In Certificate #1, we see that Alice Smith works in the Technical Services division of Carillon. Now, at Carillon, we issue certificates with additional information in the CN, to make choosing which certificate (Identity, Signature, or Encryption) a user wants to use for a given task easier. We have to do it this way, since there is no good way to tell the difference between an Identity Certificate and a Signature Certificate, and there are many limits on what a program such as Internet Explorer will display to the user when a server asks for it to present a client certificate. As a general rule, a Certificate Authority will explain in its Certificate Policy how it names users. If this Certificate Policy is in RFC 3647 format, this will be found in sections 3.1.2, 3.1.4, and 3.1.5. In Certificates #2 and #3, you can see that once again, we're looking at Certificates for a Subscriber named Alice Smith. However, we also have to look at the serialNumber field to know WHICH Alice Smith we are identifying. This is because the Certificate Authority that issues these certificates guarnatees name uniqueness by including the employee number in the serialNumber field. Realistically, one would not have to look at the commonName field at all, and just match the value of the serialNumber field with whatever is being used behind the scenes to validate identity. Certificate #4 is included to show an alternate encoding of a Disinguished Name, using Domain Component (DC) names. This is the format that is native to Microsoft Active Directory, so applications that need to accept Certificates issued by a Microsoft Certificate Authority will need to be able to understand this form of Distinguished Name as well. Now, there is another place in the certificate where identity information may be found. That's the 'subjectAltName', or Subject Alternative Name, extension. This is an X.509 extension that contains one or more values of the form type:value (Note to ASN.1 purists: This is a conceptual shortcut - those curious about the actual encoding of the bits can look at RFC 5280). Some common types are:
How do you decide which certificates to trust? It gets more complicated when your application must work in a bridge environment, such as that formed by the US Federal Bridge PKI, CertiPath, the Government of Canada PKI Federal Bridge, or SAFE. In these environments, what is best practice is to use a single trust anchor belonging to one of the bridge members, and then use the Path Discovery and Validation algorithm in chapter 6 of RFC 5280 to resolve the trust of any given client certificate that is presented. Is the certificate presented allowed to be used for this purpose?
The meanings of these values are listed in RFC 5280, but a simplifying assumption can be made. In most regimes (and it is certainly best practice as promoted by NIST and ETSI), you should not have a certificate used for more than one purpose. Therefore, you need to check with your Certificate Authority, and see how they distinguish between their Identity, Signature, and Encryption certificates (for instance, CertiPath, in Section 10 of their Policy describes different profiles for each certificate use. Once you know this, you should make sure that the certificate presented is being used in the manner that the Certificate Authority wishes. If they do not make a distinction, then you should still check this field, especially in light of the restrictions outlined in RFC 5280. Once you have made the basic distinction, you should then check the extendedKeyUsage extension, if present, and see if there are any further restrictions put on the use of this certificate. According to RFC 5280, populating a value in extendedKeyUsage means that that certificate may only be used for that purpose. So, a certificate with only "Client Authentication" could not be used for Secure Email, and a certificate with only "Microsoft SmartCard Login" could not be used for web site client authentication. Consequently, your application should very carefully examine this field, and make sure that it is only accepting certificates that the Certificate Authority deems appropriate. One last thing to mention here is something called "extension criticality". Under the technical specification for X.509 Certificates, many extensions can be marked as "critical". If an extension is so marked, then an application absolutely must follow the indications and limitations of the contents of that extension. If you application does not know how to process a given critical extension, then it must reject the certificate containing that critical extension as invalid. How are you making sure that all of the certificates are valid? Revocation checking is done by validating that the serial number of the certificate being validated does not appear on the Certificate Revocation List (CRL) issued by the same entity as is listed in the "Issuer" field of the Certificate. (This is a bit of a simplification, since the Issuer can delegate CRL functionality to another entity.) If this is the case for the Certificate Authority that you've decided to trust, please see RFC 5280, section 4.2.1.13, and the discussion on "crlIssuer". The URL to find this CRL information is usually included in the X.509 extension 'crlDistributionPoints', and usually indicates that an application can use the HTTP protocol or the LDAP protocol to download it. In the case where more than one URL is listed, it is good practice to try each in turn, and stop after one is successful. If a certificate does not contain a CRL distribution point, then an application only has one option, and that is to have a configuration option that specifies the CRL location for that Certificate Authority, and use that when necessary. Another way of checking revocation that is gaining popularity is the use of the Online Certificate Status Protocol (OCSP). Use of this protocol is often faster, since, unless carefully managed and properly cached, CRL fetching can rapidly cause network and performance problems, due to their size (there are anecdotal accounts of CRLs of several MB begin generated by certain long running PKI implementations). Again, most certificates have a pointer to an OCSP server that has information about them, in the OCSP value of the 'authorityInformationAccess' extension. It is worth stressing that not only the client certificate, but every certificate in your trust chain needs to be validated by checking either CRL or OCSP, with one exception, and that is your trust anchor. Trust Anchors are never listed in a CRL, and they are not revoked in the normal manner. The only way to mark a trust anchor as untrusted is to remove it from the list of trust anchors. This is why, as listed in the section on trust anchors, it is critical to have a good process for trust anchor management. How are you making sure that all of the certificates are issued according to a policy that you agree with? What about all of the encryption stuff? Certificates are used in order to establish the symmetric key that both sides will use to actually encrypt the data. As has already been hinted, encrypting data with RSA is very, very slow, whereas encrypting data with a symmetric algorithm such as AES is very fast. So, the designers of the various common cryptographic protocols restricted the use of asymmetric protocols to simply setting up and agreeing on the symmetric keys that will be used for the real encryption of the data. This use of certificates for key propagation is an optimisation, since in the environment which most of the protocols were designed (the military), applications cared very much about not only keeping people from seeing the data (encrypting it), but also ensuring exactly who was party to the conversation (authentication). And thus, protocols that do both are more efficient than two that do only half the job each. The use of a CA also allowed parties who may have never met to establish authentication with each other, and, once authenticated, establish secure communications with each other. This all sounds complicated. Is there any way to make this simpler? We also publish extensive guides to setting up your own CA that would be usable to help you test your application. If you don't wish to set up your own, Carillon can provide test certificates that are cross-certified with the CertiPath bridge at test level. Why not contact us, and find out how we can help you get a head start on integrating PKI in your application? Did this guide answer your PKI Implementation questions? |
|

