{
    "mode": "man",
    "parameter": "proxy-certificates",
    "section": "7ssl",
    "url": "https://www.chedong.com/phpMan.php/man/proxy-certificates/7ssl/json",
    "generated": "2026-10-09T03:09:19Z",
    "sections": {
        "NAME": {
            "content": "proxy-certificates - Proxy certificates in OpenSSL\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Proxy certificates are defined in RFC 3820.  They are used to extend rights to some other\nentity (a computer process, typically, or sometimes to the user itself).  This allows the\nentity to perform operations on behalf of the owner of the EE (End Entity) certificate.\n\nThe requirements for a valid proxy certificate are:\n\n•   They  are  issued  by  an  End  Entity,  either a normal EE certificate, or another proxy\ncertificate.\n\n•   They must not have the subjectAltName or issuerAltName extensions.\n\n•   They must have the proxyCertInfo extension.\n\n•   They must have the subject of their issuer, with one commonName added.\n",
            "subsections": [
                {
                    "name": "Enabling proxy certificate verification",
                    "content": "OpenSSL expects applications that want to use proxy certificates to  be  specially  aware  of\nthem, and make that explicit.  This is done by setting an X509 verification flag:\n\nX509STORECTXsetflags(ctx, X509VFLAGALLOWPROXYCERTS);\n\nor\n\nX509VERIFYPARAMsetflags(param, X509VFLAGALLOWPROXYCERTS);\n\nSee \"NOTES\" for a discussion on this requirement.\n"
                },
                {
                    "name": "Creating proxy certificates",
                    "content": "Creating  proxy  certificates  can be done using the openssl-x509(1) command, with some extra\nextensions:\n\n[ proxy ]\n# A proxy certificate MUST NEVER be a CA certificate.\nbasicConstraints = CA:FALSE\n# Usual authority key ID\nauthorityKeyIdentifier = keyid,issuer:always\n# The extension which marks this certificate as a proxy\nproxyCertInfo = critical,language:id-ppl-anyLanguage,pathlen:1,policy:text:AB\n\nIt's also possible to specify the proxy extension in a separate section:\n\nproxyCertInfo = critical,@proxyext\n\n[ proxyext ]\nlanguage = id-ppl-anyLanguage\npathlen = 0\npolicy = text:BC\n\nThe policy value has a specific syntax, syntag:string, where the syntag determines what  will\nbe done with the string.  The following syntags are recognised:\n"
                },
                {
                    "name": "text",
                    "content": "indicates that the string is a byte sequence, without any encoding:\n\npolicy=text:räksmörgås\n\nhex indicates the string is encoded hexadecimal encoded binary data, with colons between each\nbyte (every second hex digit):\n\npolicy=hex:72:E4:6B:73:6D:F6:72:67:E5:73\n"
                },
                {
                    "name": "file",
                    "content": "indicates  that the text of the policy should be taken from a file.  The string is then a\nfilename.  This is useful for policies that are more than a few lines,  such  as  XML  or\nother markup.\n\nNote  that the proxy policy value is what determines the rights granted to the process during\nthe proxy certificate, and it is up  to  the  application  to  interpret  and  combine  these\npolicies.>\n\nWith a proxy extension, creating a proxy certificate is a matter of two commands:\n\nopenssl req -new -config proxy.cnf \\\n-out proxy.req -keyout proxy.key \\\n-subj \"/DC=org/DC=openssl/DC=users/CN=proxy\"\n\nopenssl x509 -req -CAcreateserial -in proxy.req -out proxy.crt \\\n-CA user.crt -CAkey user.key -days 7 \\\n-extfile proxy.cnf -extensions proxy\n\nYou  can also create a proxy certificate using another proxy certificate as issuer. Note that\nthis example uses a different configuration section for the proxy extensions:\n\nopenssl req -new -config proxy.cnf \\\n-out proxy2.req -keyout proxy2.key \\\n-subj \"/DC=org/DC=openssl/DC=users/CN=proxy/CN=proxy 2\"\n\nopenssl x509 -req -CAcreateserial -in proxy2.req -out proxy2.crt \\\n-CA proxy.crt -CAkey proxy.key -days 7 \\\n-extfile proxy.cnf -extensions proxy2\n"
                },
                {
                    "name": "Using proxy certs in applications",
                    "content": "To interpret proxy policies, the application would normally start with  some  default  rights\n(perhaps  none  at all), then compute the resulting rights by checking the rights against the\nchain of proxy certificates, user certificate and CA certificates.\n\nThe complicated part is figuring out how to  pass  data  between  your  application  and  the\ncertificate validation procedure.\n\nThe following ingredients are needed for such processing:\n\n•   a  callback  function  that  will  be  called for every certificate being validated.  The\ncallback is called several times for each certificate, so you must be careful to  do  the\nproxy  policy  interpretation  at  the right time.  You also need to fill in the defaults\nwhen the EE certificate is checked.\n\n•   a data structure that is shared between your application code and the callback.\n\n•   a wrapper function that sets it all up.\n\n•   an exdata index function that creates an index into the generic exdata  store  that  is\nattached to an X509 validation context.\n\nThe following skeleton code can be used as a starting point:\n\n#include <string.h>\n#include <netdb.h>\n#include <openssl/x509.h>\n#include <openssl/x509v3.h>\n\n#define totalrights 25\n\n/*\n* In this example, I will use a view of granted rights as a bit\n* array, one bit for each possible right.\n*/\ntypedef struct yourrights {\nunsigned char rights[(totalrights + 7) / 8];\n} YOURRIGHTS;\n\n/*\n* The following procedure will create an index for the exdata\n* store in the X509 validation context the first time it's\n* called.  Subsequent calls will return the same index.\n*/\nstatic int getproxyauthexdataidx(X509STORECTX *ctx)\n{\nstatic volatile int idx = -1;\n\nif (idx < 0) {\nX509STORElock(X509STORECTXget0store(ctx));\nif (idx < 0) {\nidx = X509STORECTXgetexnewindex(0,\n\"for verify callback\",\nNULL,NULL,NULL);\n}\nX509STOREunlock(X509STORECTXget0store(ctx));\n}\nreturn idx;\n}\n\n/* Callback to be given to the X509 validation procedure.  */\nstatic int verifycallback(int ok, X509STORECTX *ctx)\n{\nif (ok == 1) {\n/*\n* It's REALLY important you keep the proxy policy check\n* within this section.  It's important to know that when\n* ok is 1, the certificates are checked from top to\n* bottom.  You get the CA root first, followed by the\n* possible chain of intermediate CAs, followed by the EE\n* certificate, followed by the possible proxy\n* certificates.\n*/\nX509 *xs = X509STORECTXgetcurrentcert(ctx);\n\nif (X509getextensionflags(xs) & EXFLAGPROXY) {\nYOURRIGHTS *rights =\n(YOURRIGHTS *)X509STORECTXgetexdata(ctx,\ngetproxyauthexdataidx(ctx));\nPROXYCERTINFOEXTENSION *pci =\nX509getextd2i(xs, NIDproxyCertInfo, NULL, NULL);\n\nswitch (OBJobj2nid(pci->proxyPolicy->policyLanguage)) {\ncase NIDIndependent:\n/*\n* Do whatever you need to grant explicit rights\n* to this particular proxy certificate, usually\n* by pulling them from some database.  If there\n* are none to be found, clear all rights (making\n* this and any subsequent proxy certificate void\n* of any rights).\n*/\nmemset(rights->rights, 0, sizeof(rights->rights));\nbreak;\ncase NIDidpplinheritAll:\n/*\n* This is basically a NOP, we simply let the\n* current rights stand as they are.\n*/\nbreak;\ndefault:\n/*\n* This is usually the most complex section of\n* code.  You really do whatever you want as long\n* as you follow RFC 3820.  In the example we use\n* here, the simplest thing to do is to build\n* another, temporary bit array and fill it with\n* the rights granted by the current proxy\n* certificate, then use it as a mask on the\n* accumulated rights bit array, and voilà, you\n* now have a new accumulated rights bit array.\n*/\n{\nint i;\nYOURRIGHTS tmprights;\nmemset(tmprights.rights, 0,\nsizeof(tmprights.rights));\n\n/*\n* processrights() is supposed to be a\n* procedure that takes a string and its\n* length, interprets it and sets the bits\n* in the YOURRIGHTS pointed at by the\n* third argument.\n*/\nprocessrights((char *) pci->proxyPolicy->policy->data,\npci->proxyPolicy->policy->length,\n&tmprights);\n\nfor(i = 0; i < totalrights / 8; i++)\nrights->rights[i] &= tmprights.rights[i];\n}\nbreak;\n}\nPROXYCERTINFOEXTENSIONfree(pci);\n} else if (!(X509getextensionflags(xs) & EXFLAGCA)) {\n/* We have an EE certificate, let's use it to set default! */\nYOURRIGHTS *rights =\n(YOURRIGHTS *)X509STORECTXgetexdata(ctx,\ngetproxyauthexdataidx(ctx));\n\n/*\n* The following procedure finds out what rights the\n* owner of the current certificate has, and sets them\n* in the YOURRIGHTS structure pointed at by the\n* second argument.\n*/\nsetdefaultrights(xs, rights);\n}\n}\nreturn ok;\n}\n\nstatic int myX509verifycert(X509STORECTX *ctx,\nYOURRIGHTS *neededrights)\n{\nint ok;\nint (*saveverifycb)(int ok,X509STORECTX *ctx) =\nX509STORECTXgetverifycb(ctx);\nYOURRIGHTS rights;\n\nX509STORECTXsetverifycb(ctx, verifycallback);\nX509STORECTXsetexdata(ctx, getproxyauthexdataidx(ctx),\n&rights);\nX509STORECTXsetflags(ctx, X509VFLAGALLOWPROXYCERTS);\nok = X509verifycert(ctx);\n\nif (ok == 1) {\nok = checkneededrights(rights, neededrights);\n}\n\nX509STORECTXsetverifycb(ctx, saveverifycb);\n\nreturn ok;\n}\n\nIf  you  use  SSL  or  TLS, you can easily set up a callback to have the certificates checked\nproperly, using the code above:\n\nSSLCTXsetcertverifycallback(sctx, myX509verifycert,\n&neededrights);\n"
                }
            ]
        },
        "NOTES": {
            "content": "To this date, it seems that proxy certificates have only been used in environments  that  are\naware  of them, and no one seems to have investigated how they can be used or misused outside\nof such an environment.\n\nFor that reason, OpenSSL requires that applications aware of  proxy  certificates  must  also\nmake that explicit.\n\nsubjectAltName and issuerAltName are forbidden in proxy certificates, and this is enforced in\nOpenSSL.  The subject must be the same as the issuer, with one commonName added on.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "X509STORECTXsetflags(3), X509STORECTXsetverifycb(3), X509VERIFYPARAMsetflags(3),\nSSLCTXsetcertverifycallback(3),     openssl-req(1),     openssl-x509(1),     RFC    3820\n<https://tools.ietf.org/html/rfc3820>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.\n\nLicensed under the Apache License 2.0 (the \"License\").  You may not use this file  except  in\ncompliance  with  the  License.   You  can  obtain  a  copy in the file LICENSE in the source\ndistribution or at <https://www.openssl.org/source/license.html>.\n\n3.0.13                                       2026-07-29                     PROXY-CERTIFICATES(7SSL)",
            "subsections": []
        }
    },
    "summary": "proxy-certificates - Proxy certificates in OpenSSL",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "X509STORECTXsetflags",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/X509STORECTXsetflags/3/json"
        },
        {
            "name": "X509STORECTXsetverifycb",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/X509STORECTXsetverifycb/3/json"
        },
        {
            "name": "X509VERIFYPARAMsetflags",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/X509VERIFYPARAMsetflags/3/json"
        },
        {
            "name": "SSLCTXsetcertverifycallback",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/SSLCTXsetcertverifycallback/3/json"
        },
        {
            "name": "openssl-req",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/openssl-req/1/json"
        },
        {
            "name": "openssl-x509",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/openssl-x509/1/json"
        }
    ]
}