PROXY-CERTIFICATES(7SSL)
β¨ proxy-certificates β Proxy certificates in OpenSSL β¨
okay bestie, pull up a chair πͺ because we are diving into proxy-certificates from the OpenSSL 7SSL manual, and honestly? it's giving β¨delegationβ¨
πΈ DESCRIPTION πΈ
Proxy certificates are defined in RFC 3820, periodt. They're used to extend rights to some other entity β usually a computer process, sometimes literally the user themself β and that lets the entity do operations on behalf of the owner of the EE (End Entity) certificate. it's giving "you go do this for me, i trust you" energy π«Ά
So the requirements for a valid proxy certificate are, no cap:
- They are issued by an End Entity, either a normal EE certificate, or another proxy certificate. π
- They must not have the
subjectAltNameorissuerAltNameextensions. π« - They must have the
proxyCertInfoextension. π - They must have the subject of their issuer, with one
commonNameadded.
π Enabling proxy certificate verification
OpenSSL is not out here guessing. It expects applications that want to use proxy certificates to be specially aware of them and to make that explicit. so loud, so clear. π
You do that by setting an X509 verification flag, like so:
X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
or, alternatively:
X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_ALLOW_PROXY_CERTS);
and if you want the whole discussion on why this requirement exists, go read "NOTES" π (yes, there's a whole thing).
π Creating proxy certificates
Making proxy certificates is a openssl-x509(1) command situation, plus some extra extensions. look at her go β¨
[ proxy ]
# A proxy certificate MUST NEVER be a CA certificate.
basicConstraints = CA:FALSE
# Usual authority key ID
authorityKeyIdentifier = keyid,issuer:always
# The extension which marks this certificate as a proxy
proxyCertInfo = critical,language:id-ppl-anyLanguage,pathlen:1,policy:text:AB
β οΈ real talk: a proxy certificate MUST NEVER be a CA certificate. that comment is right there in the config for a reason, bestie.
You can also stash the proxy extension in its own separate section if that's more your vibe:
proxyCertInfo = critical,@proxy_ext
[ proxy_ext ]
language = id-ppl-anyLanguage
pathlen = 0
policy = text:BC
Now, the policy value has its own specific syntax: syntag:string, where the syntag decides what actually gets done with the string. π§ the recognised syntags are:
textβ means the string is a byte sequence, with zero encoding whatsoever:
policy=text:rΓ€ksmΓΆrgΓ₯s
hexβ means the string is hex-encoded binary data, with colons between each byte (so, every second hex digit):
policy=hex:72:E4:6B:73:6D:F6:72:67:E5:73
fileβ means the text of the policy should be pulled from a file. the string is then a filename. π this one is a lifesaver for policies that are more than a few lines, like XML or other markup.
heads up bestie: the proxy policy value is what determines the rights granted to the process during the proxy certificate, and it is up to the application to interpret and combine these policies.> (and yes, that stray > is literally in the original. we don't know her. we keep her. π)
So with a proxy extension in hand, creating a proxy certificate is a matter of two commands β two! iconic:
openssl req -new -config proxy.cnf \
-out proxy.req -keyout proxy.key \
-subj "/DC=org/DC=openssl/DC=users/CN=proxy"
openssl x509 -req -CAcreateserial -in proxy.req -out proxy.crt \
-CA user.crt -CAkey user.key -days 7 \
-extfile proxy.cnf -extensions proxy
You can also create a proxy certificate using another proxy certificate as the issuer. queen behaviour π note that this example uses a different configuration section for the proxy extensions:
openssl req -new -config proxy.cnf \
-out proxy2.req -keyout proxy2.key \
-subj "/DC=org/DC=openssl/DC=users/CN=proxy/CN=proxy 2"
openssl x509 -req -CAcreateserial -in proxy2.req -out proxy2.crt \
-CA proxy.crt -CAkey proxy.key -days 7 \
-extfile proxy.cnf -extensions proxy_2
π¦ Using proxy certs in applications
To interpret proxy policies, your application would normally start with some default rights (maybe none at all, honestly), then compute the resulting rights by checking those rights against the chain of proxy certificates, user certificate and CA certificates. it's a whole journey. π
The complicated part β the real main character struggle β is figuring out how to pass data between your application and the certificate validation procedure. π
The following ingredients are needed for such processing:
- a callback function that will be called for every certificate being validated. heads up: the callback is called several times for each certificate, so you must be careful to do the proxy policy interpretation at the right time. you also need to fill in the defaults when the EE certificate is checked. β
- a data structure that is shared between your application code and the callback.
- a wrapper function that sets it all up.
- an
ex_dataindex function that creates an index into the genericex_datastore that is attached to an X509 validation context.
The following skeleton code can be used as a starting point. slay π
#include <string.h>
#include <netdb.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#define total_rights 25
/*
* In this example, I will use a view of granted rights as a bit
* array, one bit for each possible right.
*/
typedef struct your_rights {
unsigned char rights[(total_rights + 7) / 8];
} YOUR_RIGHTS;
/*
* The following procedure will create an index for the ex_data
* store in the X509 validation context the first time it's
* called. Subsequent calls will return the same index.
*/
static int get_proxy_auth_ex_data_idx(X509_STORE_CTX *ctx)
{
static volatile int idx = -1;
if (idx < 0) {
X509_STORE_lock(X509_STORE_CTX_get0_store(ctx));
if (idx < 0) {
idx = X509_STORE_CTX_get_ex_new_index(0,
"for verify callback",
NULL,NULL,NULL);
}
X509_STORE_unlock(X509_STORE_CTX_get0_store(ctx));
}
return idx;
}
/* Callback to be given to the X509 validation procedure. */
static int verify_callback(int ok, X509_STORE_CTX *ctx)
{
if (ok == 1) {
/*
* It's REALLY important you keep the proxy policy check
* within this section. It's important to know that when
* ok is 1, the certificates are checked from top to
* bottom. You get the CA root first, followed by the
* possible chain of intermediate CAs, followed by the EE
* certificate, followed by the possible proxy
* certificates.
*/
X509 *xs = X509_STORE_CTX_get_current_cert(ctx);
if (X509_get_extension_flags(xs) & EXFLAG_PROXY) {
YOUR_RIGHTS *rights =
(YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
get_proxy_auth_ex_data_idx(ctx));
PROXY_CERT_INFO_EXTENSION *pci =
X509_get_ext_d2i(xs, NID_proxyCertInfo, NULL, NULL);
switch (OBJ_obj2nid(pci->proxyPolicy->policyLanguage)) {
case NID_Independent:
/*
* Do whatever you need to grant explicit rights
* to this particular proxy certificate, usually
* by pulling them from some database. If there
* are none to be found, clear all rights (making
* this and any subsequent proxy certificate void
* of any rights).
*/
memset(rights->rights, 0, sizeof(rights->rights));
break;
case NID_id_ppl_inheritAll:
/*
* This is basically a NOP, we simply let the
* current rights stand as they are.
*/
break;
default:
/*
* This is usually the most complex section of
* code. You really do whatever you want as long
* as you follow RFC 3820. In the example we use
* here, the simplest thing to do is to build
* another, temporary bit array and fill it with
* the rights granted by the current proxy
* certificate, then use it as a mask on the
* accumulated rights bit array, and voilΓ , you
* now have a new accumulated rights bit array.
*/
{
int i;
YOUR_RIGHTS tmp_rights;
memset(tmp_rights.rights, 0,
sizeof(tmp_rights.rights));
/*
* process_rights() is supposed to be a
* procedure that takes a string and its
* length, interprets it and sets the bits
* in the YOUR_RIGHTS pointed at by the
* third argument.
*/
process_rights((char *) pci->proxyPolicy->policy->data,
pci->proxyPolicy->policy->length,
&tmp_rights);
for(i = 0; i < total_rights / 8; i++)
rights->rights[i] &= tmp_rights.rights[i];
}
break;
}
PROXY_CERT_INFO_EXTENSION_free(pci);
} else if (!(X509_get_extension_flags(xs) & EXFLAG_CA)) {
/* We have an EE certificate, let's use it to set default! */
YOUR_RIGHTS *rights =
(YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
get_proxy_auth_ex_data_idx(ctx));
/*
* The following procedure finds out what rights the
* owner of the current certificate has, and sets them
* in the YOUR_RIGHTS structure pointed at by the
* second argument.
*/
set_default_rights(xs, rights);
}
}
return ok;
}
static int my_X509_verify_cert(X509_STORE_CTX *ctx,
YOUR_RIGHTS *needed_rights)
{
int ok;
int (*save_verify_cb)(int ok,X509_STORE_CTX *ctx) =
X509_STORE_CTX_get_verify_cb(ctx);
YOUR_RIGHTS rights;
X509_STORE_CTX_set_verify_cb(ctx, verify_callback);
X509_STORE_CTX_set_ex_data(ctx, get_proxy_auth_ex_data_idx(ctx),
&rights);
X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
ok = X509_verify_cert(ctx);
if (ok == 1) {
ok = check_needed_rights(rights, needed_rights);
}
X509_STORE_CTX_set_verify_cb(ctx, save_verify_cb);
return ok;
}
okay bestie and if you're living that SSL / TLS life?? you can literally just drop a callback in so the certs get checked the right way, using the code above, no cap:
SSL_CTX_set_cert_verify_callback(s_ctx, my_X509_verify_cert,
&needed_rights);
likeβ¦ that's it. that's the whole vibe. β¨
π NOTES π
ngl, as of right now β like, to this date β it seems that proxy certificates have only ever been used in environments that already know about them, and nobody seems to have gone digging into how they could be used or misused outside of that kind of environment. π the lore is genuinely unfinished, i fear.
and that's exactly why OpenSSL is like: no. apps that are aware of proxy certificates have to make that explicit themselves. no sneaky auto-magic, no assumptions, you say it out loud or it doesn't happen. periodt. π
also forbidden in proxy certificates: subjectAltName and issuerAltName β and this is enforced in OpenSSL, so don't even try it, it's giving instant fail. π«
and the subject? it has to be the same as the issuer, with one commonName added on. that's the whole recipe. same-same but with a lil extra commonName sprinkled on top. π
π SEE ALSO π
the extended universe, go read it, it's so worth it:
X509_STORE_CTX_set_flags(3)X509_STORE_CTX_set_verify_cb(3)X509_VERIFY_PARAM_set_flags(3)SSL_CTX_set_cert_verify_callback(3)openssl-req(1)openssl-x509(1)RFC 3820βhttps://tools.ietf.org/html/rfc3820
iykyk, that RFC is the source material fr fr π
Β©οΈ COPYRIGHT Β©οΈ
Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.
and that's a wrap on this one, bestie π this was version 4.0.3, dated 2026-09-29, of PROXY-CERTIFICATES(7SSL). go forth, check your certs, stay explicit about your proxy awareness, and slay π«ΆπΈβ¨
π¦ where this page comes from
- ubuntu stonking: openssl 4.0.3-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms