title: X.509v3 ASN.1 to C datastructs
body: <p>I'm trying to create a X509 Request for a Proxy Certificate (ProxyCertInfo Extension <a href="http://www.ietf.org/rfc/rfc3820.txt" rel="nofollow">RFC3820</a>) in C (OpenSSL), but I cannot figure out how the datastructures of the ProxyCertInfo should be defined. The RFC defines the ASN.1 language as follows:</p>
  
  <pre><code>PKIXproxy88 { iso(1) identified-organization(3) dod(6)
     internet(1) security(5) mechanisms(5) pkix(7) id-mod(0)
     proxy-cert-extns(25) }
  
  DEFINITIONS EXPLICIT TAGS ::=
  
  BEGIN
  
  -- EXPORTS ALL --
  
  -- IMPORTS NONE --
  
  -- PKIX specific OIDs
  
  id-pkix OBJECT IDENTIFIER ::=
         { iso(1) identified-organization(3)
              dod(6) internet(1) security(5) mechanisms(5) pkix(7) }
  
  -- private certificate extensions
  id-pe   OBJECT IDENTIFIER ::= { id-pkix 1 }
  
  -- Locally defined OIDs
  
  -- The proxy certificate extension
  id-pe-proxyCertInfo    OBJECT IDENTIFIER ::= { id-pe 14 }
  
  -- Proxy certificate policy languages
  id-ppl  OBJECT IDENTIFIER ::= { id-pkix 21 }
  
  -- Proxy certificate policies languages defined in
  id-ppl-anyLanguage     OBJECT IDENTIFIER ::= { id-ppl 0 }
  id-ppl-inheritAll      OBJECT IDENTIFIER ::= { id-ppl 1 }
  id-ppl-independent     OBJECT IDENTIFIER ::= { id-ppl 2 }
  
  -- The ProxyCertInfo Extension
  ProxyCertInfoExtension  ::= SEQUENCE {
       pCPathLenConstraint     ProxyCertPathLengthConstraint OPTIONAL,
       proxyPolicy             ProxyPolicy
  }
  
  ProxyCertPathLengthConstraint  ::= INTEGER
  ProxyPolicy  ::= SEQUENCE {
       policyLanguage          OBJECT IDENTIFIER,
       policy                  OCTET STRING OPTIONAL
  }
  
  END
  </code></pre>
  
  <p>I have looked at the very limited documentation of OpenSSL and cannot find out how to parse this to C data structs. I've also read <a href="http://www.openssl.org/docs/apps/asn1parse.html#" rel="nofollow">http://www.openssl.org/docs/apps/asn1parse.html#</a> as it explains how to use the parser for the command line tool, but not how to include this in your own source code.</p>
  
  <p>I have managed to include other extensions to the X509 request already, so I'm relatively sure my only problem is with the formatting of the data structures for this particular extension.</p>