<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>digital signature on Digi Hunch</title><link>https://www.digihunch.com/tag/digital-signature/</link><description>Recent content in digital signature on Digi Hunch</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Sat, 20 Jul 2024 18:37:01 -0400</lastBuildDate><atom:link href="https://www.digihunch.com/tag/digital-signature/index.xml" rel="self" type="application/rss+xml"/><item><title>OAuth 2.0 and OIDC 1 of 2</title><link>https://www.digihunch.com/2020/03/oauth-and-openid-connect/</link><pubDate>Sat, 14 Mar 2020 21:10:00 -0400</pubDate><guid>https://www.digihunch.com/2020/03/oauth-and-openid-connect/</guid><description>&lt;p class="wp-block-paragraph"&gt;OAuth 2.0 and OpenID Connect (OIDC 1.0) are different but highly related protocols and they are often confused. When we talk about IAM (identity and access management), we should first distinguish between Authentication (AuthN) and Authorization (AuthZ):&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;AutheNtication (AuthN, aka Identity Management) is about validating user&amp;#8217;s identity by verifying that the user trying to connect is actually who it claims itself to be;&lt;/li&gt;&#10;&lt;li&gt;AuthoriZation (AuthZ, aka Access Management) refers to granting or denying access to specific resources based on the requesting user&amp;#8217;s identity. It is usually performed after a user is identified through authentication. The most common approach is Role-Based Access Control (RBAC).&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In a nutshell, OAuth 2.0 deals with authorization. OIDC is a layer later developed on top of OAuth 2.0, to deal with authentication. This post is greatly influenced by a &lt;a href="https://www.youtube.com/watch?v=996OiexHze0"&gt;presentation&lt;/a&gt; (1 hour) delivered by Nate Barbettini from Okta, with the slides available &lt;a href="https://speakerdeck.com/nbarbettini/oauth-and-openid-connect-in-plain-english"&gt;here&lt;/a&gt;. There is also an abridged and illustrated video (16 min) by Okta available &lt;a href="https://www.youtube.com/watch?v=t18YB3xDfXI"&gt;here&lt;/a&gt;.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="oauth-2-0"&gt;OAuth 2.0&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;OAuth was originally developed by Twitter and Google in 2006 as an open standard for API authorization. &lt;strong&gt;OAuth 2.0&lt;/strong&gt; is published in 2012. It allows user to &lt;span style="text-decoration: underline;"&gt;delegate authorization&lt;/span&gt;. The original scenario is a user signed up to a new application and allows it to automatically import her Gmail contact. The technical problem to solve is: how can a user (Resource Owner) let an app (Client) to access his contact list stored in Google server (Resource Server)? The proposal is that it redirects user to Google Account page (Authorization Server) for user to log in. Then Google Account issues token to the application (Client) with user&amp;#8217;s approval. Note that the user did NOT log in to the application itself with her Google account. From the application&amp;#8217;s standpoint, the user had been authenticated already, and was simply importing contact after logging in. The roles involved in OAuth 2.0 are:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Resource: the contact list of the user&lt;/li&gt;&#10;&lt;li&gt;Resource owner: the user&lt;/li&gt;&#10;&lt;li&gt;Client: the application&lt;/li&gt;&#10;&lt;li&gt;Resource Server: contact.google.com&lt;/li&gt;&#10;&lt;li&gt;Authorization Server: accounts.google.com&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The diagram below illustrates the interactions:&lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter"&gt;&lt;img decoding="async" src="https://assets.digitalocean.com/articles/oauth/auth_code_flow.png" alt="Authorization Code Flow"/&gt;&lt;figcaption class="wp-element-caption"&gt;OAuth 2.0 Authorization Code Flow&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2"&gt;This&lt;/a&gt; page has further details for each step. Note that at step 3 to 5 may seem unnecessary because Auth Server could have send Access Token Grant to Application via User-Agent at step 3, which could have eliminate the need for step 4 and 5. In fact this design is to avoid sending critical information (Access Token Grant) to User-Agent (browser) which is considered in secure. In other words, it avoids front channel (User-agent to auth server) and prefers back channel (Client to Auth server) for security. This is the difference between Authorization code flow and the implicit flow.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;With OAuth 2.0, there are a number of flows:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Authorization code (front channel and back channel)&lt;/li&gt;&#10;&lt;li&gt;Implicit (front channel only, token returned to user agent directly)&lt;/li&gt;&#10;&lt;li&gt;Resource owner password credentials (back channel only)&lt;/li&gt;&#10;&lt;li&gt;Client credentials (back channel only)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In Authorization Code Flow, the Application (client) needs a one-time registration with the Auth Server and is given a client ID and client secret, which are sent to Auth Server at step 4 along with Access Token Request, to prove the identity of the client application.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Note that OAuth 2.0 is an inherently insecure protocol since it does not support signature, encryption, channel binding or client verification. The protocol relies entirely on the underlying transport layer security (TLS) to provide confidentiality and integrity.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Also note that throughout the process (Authorization Code Flow as an example), the Client application eventually is granted access to user&amp;#8217;s data. However, it does not know anything about the user itself. Neither the authorization code grant, nor the access token grant is &lt;span style="text-decoration: underline;"&gt;obligated&lt;/span&gt; to present information about the user itself. Therefore, OAuth 2.0 is designed strictly for permission purpose without the intent to address identity issue. In the flow, the auth server does the authentication (for the purpose of granting access to resources, but none of the authentication. A user logs in to client application as Bob, when he requests to imports contact, he is redirected to account.google.com and there he could put in the credential of Alice and therefore load Alice&amp;#8217;s Google contacts into Bob&amp;#8217;s App account!&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="pseudo-authentication-with-oauth-2-0"&gt;Pseudo-authentication with OAuth 2.0&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In many real life OAuth 2.0 implementations, at step 3, the Auth server chooses to include a field about the user&amp;#8217;s identity. This makes user&amp;#8217;s identity visible to the client, and the client is therefore able to confirm user&amp;#8217;s identity in its own code. This also allows client application to use OAuth 2.0 as an authentication method, which is referred to as pseudo-authentication. The access token acts as a kind of &amp;#8220;valet key&amp;#8221; that the application can include with its request to the auth server, as a proof that it has user&amp;#8217;s permission to access the resources (or APIs).&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Because the identity provider (auth server) typically (but not always) authenticates the user as part of the process of granting an OAuth access token, it&amp;#8217;s tempting to view a successful OAuth access token request as an authentication method itself. However, because OAuth was not designed with this use case in mind, making this assumption can lead to major security flaws.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Nate&amp;#8217;s presentation outlined some scenarios where OAuth 2.0 is applied up to 2012, and which ones are misuses:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Simple login &amp;#8211; pseudo authentication with OAuth 2.0&lt;/li&gt;&#10;&lt;li&gt;Single sign-on across sites &amp;#8211; pseudo authentication with OAuth 2.0&lt;/li&gt;&#10;&lt;li&gt;Mobile app login &amp;#8211; pseudo authentication with OAuth 2.0&lt;/li&gt;&#10;&lt;li&gt;Delegated authorization &amp;#8211; the only intended use case for OAuth 2.0&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;To address the authentication issue properly, and in a standard approach, we need OpenID Connect.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="openid-connect-oidc"&gt;OpenID Connect (OIDC) &lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;OpenID Connect is an open standard for authentication, promoted by the non-profit OpenID Foundation. It allows user to be authenticated using a third-party service called identity providers. User may choose to use their preferred OpenID Connect providers to log in to websites that accept the OpenID Connect authentication scheme. For example, a user uses her Facebook to login to an online application.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;OpenID Connect is an extension to OAuth 2.0 with a just few additions:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;In addition to access token, an ID token is returned by the authorization server;&lt;/li&gt;&#10;&lt;li&gt;Userinfo end point is provided in case Id token is not sufficient and more user information is needed;&lt;/li&gt;&#10;&lt;li&gt;&amp;#8220;openid&amp;#8221; is passed as a parameter in the Scope during the initial call to the authorization server;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Therefore OpenID Connect is considered an identity layer on top of OAuth 2.0. Many application supports OpenID Connect such as &lt;a href="https://nifi.apache.org/"&gt;Apache Nifi&lt;/a&gt;. OIDC is comparable with SAML in the sense that both provide SSO feature (federated identity). Here is a comparison table:&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&#10;&lt;table id="tablepress-6" class="tablepress tablepress-id-6"&gt;&#10;&lt;thead&gt;&#10;&lt;tr class="row-1"&gt;&#10;&#9;&lt;td class="column-1"&gt;&lt;/td&gt;&lt;th class="column-2"&gt;OpenID Connect&lt;/th&gt;&lt;th class="column-3"&gt;SAML&lt;/th&gt;&#10;&lt;/tr&gt;&#10;&lt;/thead&gt;&#10;&lt;tbody class="row-striping row-hover"&gt;&#10;&lt;tr class="row-2"&gt;&#10;&#9;&lt;td class="column-1"&gt;Main Purpose&lt;/td&gt;&lt;td class="column-2"&gt;SSO for consumer/mobile applications&lt;/td&gt;&lt;td class="column-3"&gt;SSO for enterprise applications&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr class="row-3"&gt;&#10;&#9;&lt;td class="column-1"&gt;Load&lt;/td&gt;&lt;td class="column-2"&gt;Relatively light weight&lt;/td&gt;&lt;td class="column-3"&gt;Heavy weight due to the size of XML messages &lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr class="row-4"&gt;&#10;&#9;&lt;td class="column-1"&gt;Use case&lt;/td&gt;&lt;td class="column-2"&gt;Satisfies both authentication and authorization use cases, often combined with OAuth 2.0&lt;/td&gt;&lt;td class="column-3"&gt;Generally not used for API security&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr class="row-5"&gt;&#10;&#9;&lt;td class="column-1"&gt;Transport&lt;/td&gt;&lt;td class="column-2"&gt;HTTP GET and HTTP POST&lt;/td&gt;&lt;td class="column-3"&gt;HTTP Redirect (GET) binding, SAML SOAP binding, HTTP POST binding, et&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr class="row-6"&gt;&#10;&#9;&lt;td class="column-1"&gt;&lt;/td&gt;&lt;td class="column-2"&gt;&lt;/td&gt;&lt;td class="column-3"&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://medium.com/@awskarthik82/simple-guide-to-saml-vs-oidc-33a3349189c6"&gt;Here &lt;/a&gt;are more details about their differences. In general SAML is more common in the enterprise world for SSO and it has been around for a while. When developing new applications for enterprise it is advised to consider OIDC first.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;OIDC also has authorization code flow, with the additional fields on top of its counterpart in OAuth 2.0. The authorization server returns both access and ID tokens, wrapped in a data structure named JWT (JSON Web Token). The JWT includes a signature field, allowing the client application to verify it with authorization server&amp;#8217;s public key. Nate&amp;#8217;s presentation proposes the following flows for each application type:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Web application with server backend: authorization code flow&lt;/li&gt;&#10;&lt;li&gt;Native mobile app: authorization code flow with PKCE&lt;/li&gt;&#10;&lt;li&gt;Java Script app (SPA) with API backend: implicit flow&lt;/li&gt;&#10;&lt;li&gt;Microservices and APIs: client credential flow&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In addition, &lt;a href="https://developer.okta.com/docs/concepts/oauth-openid/"&gt;this&lt;/a&gt; page from Okta developer has a good summary of how to select flow type (grant) based on each use case.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="summary"&gt;Summary&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;OpenID Connect is an authentication protocol for the purpose of validating user&amp;#8217;s identity. OAuth 2.0 is an authorization protocol. You should use OAuth 2.0 for granting access to your API, or access to user data in other systems. If you need to log user in, or make your accounts available in other systems, you need OIDC.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The &lt;a href="https://www.digihunch.com/2023/07/oauth-2-0-and-oidc-2-of-2/"&gt;next post&lt;/a&gt; about OAuth and OIDC was posted in 2023.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;br&gt; &lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2020/03/saml-security-assertion-markup-language/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Security Assertion Markup Language (SAML)&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2020/03/authentication-mechanisms-under-simple-authentication-and-security-layer-sasl/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;SASL Authentication Mechanisms&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item><item><title>Cryptography Basics 1 of 2</title><link>https://www.digihunch.com/2019/07/practical-cryptography-for-it-professional/</link><pubDate>Wed, 10 Jul 2019 20:07:18 -0400</pubDate><guid>https://www.digihunch.com/2019/07/practical-cryptography-for-it-professional/</guid><description>&lt;p class="wp-block-paragraph"&gt;I have been dabbling with OpenSSL commands to achieve what I needed during IT implementation, but I decided to spent some time to overcome the conceptual hurdles around cryptography. In this domain, following other people&amp;#8217;s instructions through the project does not produce much learning value when too many concepts cloud around. Let&amp;#8217;s take the bull by the horn.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;This article is purely conceptual. There are already lots of step-by-step guideline about acquiring a website certificate. The intention is to elucidate the core concepts on IT cryptography, and then connect the dots to form the big picture in cryptography.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;First, let&amp;#8217;s distinguish three basic concepts: encoding, hashing and encryption. They are in essence all mathematical functions, but one does not need to understand the underlying algorithm in order to understand what they are.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Encoding&lt;/strong&gt; &amp;#8211; Transform data into a format so it is readable by external system. Encoding is about interoperability. It is not about security whatsoever. Example: ASCII, BASE64, UNICODE.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Hashing&lt;/strong&gt; &amp;#8211; Mathematic algorithms to generate digest of content. A digest is usually fixed-size, non-reversible and deterministic. You cannot restore content from its digest (non-reversible, one-way calculation). Two different contents results guarantees different digests (deterministic). Digest as a result of hashing is mostly about data integrity. For example, in file download you can calculate MD5 hash and compare the result against the digest given by the source. Another common use, is to hash all password in database. In that sense, hashing has to do with security. Popular algorithms are MD5 and SHA-256.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Encryption&lt;/strong&gt; &amp;#8211; Mathematic algorithms that only succeeds if correct parameter (key) is provided. The function is deterministic and reversible (two-way). The parameter (key) used for calculation (encryption) and reverse calculation (decryption) can either be the same or different. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Cryptography involves all three concepts, but it mainly addresses issues around encryption. We break down encryption into two categories, symmetric key encryption (aka private key encryption) and asymmetric key encryption (aka public key encryption).&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Symmetric Key Encryption&lt;/strong&gt;: using the same key (shared secret) for encryption and decryption. Both parties need to keep it secret. Popular algorithm is AES.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Asymmetric Key Encryption&lt;/strong&gt;: involves a pair of public key and private key. Public key is given out to external systems. Private key is kept secret. Popular algorithm is RSA. You can run some experiments on &lt;a href="https://www.devglan.com/online-tools/rsa-encryption-decryption"&gt;this page&lt;/a&gt;, and I&amp;#8217;ve made some additional notes (all based on RSA algorithm):&lt;/p&gt;&#10;&lt;ol class="wp-block-list"&gt;&lt;li&gt;Public Key and Private Key are NOT interchangeable. The size of an RSA private key is usually much larger than its public key;&lt;/li&gt;&lt;li&gt;You can encrypt with either key, and decrypt with the other, so long as you specify the key type at the time of encryption or decryption;&lt;/li&gt;&lt;li&gt;You can generate public key from private key (ssh-keygen -y); but not the other way round;&lt;/li&gt;&lt;li&gt;Using a wrong key to encrypt or decrypt leads to failure, instead of wrong result.&lt;/li&gt;&lt;/ol&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Obviously symmetric key encryption is the original form of encryption and requires both parties to keep the key secret, permanently. This is not realistic in real life between organizations. This challenge leads to the adoption of asymmetric key where the public key can be published, for external party to encrypt outgoing messages, whereas the private key is kept secret within the owner, only to decrypt incoming messages. &lt;/p&gt;&#10;&lt;figure class="wp-block-image"&gt;&lt;img decoding="async" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Public_key_encryption.svg/1024px-Public_key_encryption.svg.png" alt=""/&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Knowing this distinction, we can introduce two concepts that are built on top of asymmetric key encryption.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Digital Signature&lt;/strong&gt;: if an entity signs a document digitally. The digital signature is the digest of the document (hash of the content) encrypted with the signer&amp;#8217;s private key.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Digital Certificate&lt;/strong&gt;: contains owner&amp;#8217;s public key and digital signature of issuer (digest of owner&amp;#8217;s public key encrypted by issuer&amp;#8217;s private key). Client (e.g. browser with CA&amp;#8217;s public key preloaded) should not trust the owner&amp;#8217;s public key until it compares its digest against decryption result of digital signature (using CA&amp;#8217;s public key).&amp;nbsp;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The key difference here is that a digital certificate involves third party. Digital signature by itself cannot address impersonation, which is addressed by digital certificate issued by third party (certified authority). This requires digital certificate must follow some standard, and the most prevalent one is:&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;X.509&lt;/strong&gt;: a standard format for digital certificates. It contains:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&lt;li&gt;a public key&lt;/li&gt;&lt;li&gt;an identity (a hostname, or&amp;nbsp; an organization, or an individual)&lt;/li&gt;&lt;li&gt;a signature (either signed by CA or self-signed)&lt;/li&gt;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Since the advent of certificate, there are tons of global organizations that need to manage keys and certificates. When we create a secure connection now, we only need to get a certificate from an intermediate CA, thanks to existing &lt;a href="https://knowledge.digicert.com/solution/SO16297.html"&gt;certificate chain&lt;/a&gt;. It involves lots of work for large organizations to maintain keys and certificates, which requires:&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Public Key Infrastructure (PKI)&lt;/strong&gt;: the IT infrastructure to create, manage, distribute, use, store and revoke digital certificates and public keys.&amp;nbsp;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;One of the important technique to manage keys and certificates is the encoding. Keys and certificates are usually wrapped with different encoding formats based on what need to be done on them. Here is a summary of encoding formats&lt;/p&gt;&#10;&lt;figure class="wp-block-table aligncenter is-style-stripes"&gt;&lt;table class="has-background" style="background-color:#e7f5fe"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Format&lt;/td&gt;&lt;td&gt;Encoding&lt;/td&gt;&lt;td&gt;what is stored&lt;/td&gt;&lt;td&gt;Possible Suffix&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;PEM&lt;/td&gt;&lt;td&gt;DER file (binary content) encoded in Base64. Certificate files typically include clear text statement &amp;#8220;BEGIN CERTIFICATE&amp;#8221; and &amp;#8220;END CERTIFICATE&amp;#8221;&lt;/td&gt;&lt;td&gt;single certificate, certificate chains or private keys&lt;/td&gt;&lt;td&gt;.pem, .crt, .cer, .key&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DER&lt;/td&gt;&lt;td&gt;Binary format in early days; it&amp;#8217;s complex and don&amp;#8217;t use unless with a specific purpose.&lt;/td&gt;&lt;td&gt;single certificate, certificate chains, or private keys&lt;/td&gt;&lt;td&gt;.der, .cer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;PKCS#7&lt;/td&gt;&lt;td&gt;Base64 encoded ASCII file, typically include clear text statement &amp;#8220;BEGIN PKCS7&amp;#8221; and &amp;#8220;END PKCS7&amp;#8221;&lt;/td&gt;&lt;td&gt;only certificates or certificate chains; no private keys&lt;/td&gt;&lt;td&gt;.p7b .p7s&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;PKCS#8&lt;/td&gt;&lt;td&gt;Similar to PEM as base64 encoded format but for storing private key only, can be password protected&lt;/td&gt;&lt;td&gt;Private key&lt;/td&gt;&lt;td&gt;.key&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;PKCS#12&lt;/td&gt;&lt;td&gt;a binary format, heavily used by Microsoft products&lt;/td&gt;&lt;td&gt;certificate, certificate chains or private keys; public private key pair&lt;/td&gt;&lt;td&gt;.pfx .p12&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;OpenSSH&lt;/td&gt;&lt;td&gt;used by OpenSSH to store public keys (as specified in RFC4253)&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;.pub&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Note: above are just encoding formats. Just by file extension you cannot tell whether the file is a key or a X.509 certificate. When you are configuring certificates, you may come across the following file extensions as well:&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;.key&lt;/strong&gt; this extension can indicate any kind of key, but usually it is a private key (used along with .crt file) &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;.csr&lt;/strong&gt; certificate signing request, including a public key and an identity required by CA. CA needs this file to issue a certificate. CSR could be encoded in Base-64 or DER&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;.cer or .crt&lt;/strong&gt; a certificate, usually in X.509 v3 (public key + identity + signature), the encoding could be PEM or DER. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;.jks&lt;/strong&gt; -&amp;gt; java key store file type. It can be either a key store (private key along with certificate) or trust store (certificate) for Java application. Refer to the section for Java applications.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In the &lt;a href="https://www.digihunch.com/2019/09/cryptographic-concepts-for-busy-it-professionals-2-of-2/"&gt;next article&lt;/a&gt;, we will examine some use case involving the concepts introduced in this post.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt; &lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2019/06/git-explained-2-of-2/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Git Explained 2 of 2&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2019/07/storage-nitty-gritty-3-of-5-nas-and-object-storage/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Storage Nitty-Gritty 3 of 5 – NAS and Object Storage&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item></channel></rss>