~ubuntu-branches/ubuntu/maverick/openssl/maverick

« back to all changes in this revision

Viewing changes to crypto/x509/x509_req.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Martin
  • Date: 2004-12-16 18:41:29 UTC
  • mto: (11.1.1 lenny)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20041216184129-z7xjkul57mh1jiha
Tags: upstream-0.9.7e
ImportĀ upstreamĀ versionĀ 0.9.7e

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
 * used and there may be more: so the list is configurable.
119
119
 */
120
120
 
121
 
static int ext_nid_list[] = { NID_ms_ext_req, NID_ext_req, NID_undef};
 
121
static int ext_nid_list[] = { NID_ext_req, NID_ms_ext_req, NID_undef};
122
122
 
123
123
static int *ext_nids = ext_nid_list;
124
124
 
143
143
}
144
144
 
145
145
STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req)
146
 
{
 
146
        {
147
147
        X509_ATTRIBUTE *attr;
148
 
        STACK_OF(X509_ATTRIBUTE) *sk;
149
148
        ASN1_TYPE *ext = NULL;
150
 
        int i;
 
149
        int idx, *pnid;
151
150
        unsigned char *p;
152
 
        if ((req == NULL) || (req->req_info == NULL))
 
151
 
 
152
        if ((req == NULL) || (req->req_info == NULL) || !ext_nids)
153
153
                return(NULL);
154
 
        sk=req->req_info->attributes;
155
 
        if (!sk) return NULL;
156
 
        for(i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) {
157
 
                attr = sk_X509_ATTRIBUTE_value(sk, i);
158
 
                if(X509_REQ_extension_nid(OBJ_obj2nid(attr->object))) {
159
 
                        if(attr->single) ext = attr->value.single;
160
 
                        else if(sk_ASN1_TYPE_num(attr->value.set))
161
 
                                ext = sk_ASN1_TYPE_value(attr->value.set, 0);
162
 
                        break;
 
154
        for (pnid = ext_nids; *pnid != NID_undef; pnid++)
 
155
                {
 
156
                idx = X509_REQ_get_attr_by_NID(req, *pnid, -1);
 
157
                if (idx == -1)
 
158
                        continue;
 
159
                attr = X509_REQ_get_attr(req, idx);
 
160
                if(attr->single) ext = attr->value.single;
 
161
                else if(sk_ASN1_TYPE_num(attr->value.set))
 
162
                        ext = sk_ASN1_TYPE_value(attr->value.set, 0);
 
163
                break;
163
164
                }
164
 
        }
165
 
        if(!ext || (ext->type != V_ASN1_SEQUENCE)) return NULL;
 
165
        if(!ext || (ext->type != V_ASN1_SEQUENCE))
 
166
                return NULL;
166
167
        p = ext->value.sequence->data;
167
168
        return d2i_ASN1_SET_OF_X509_EXTENSION(NULL, &p,
168
169
                        ext->value.sequence->length,
169
170
                        d2i_X509_EXTENSION, X509_EXTENSION_free,
170
171
                        V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
171
 
}
 
172
        }
172
173
 
173
174
/* Add a STACK_OF extensions to a certificate request: allow alternative OIDs
174
175
 * in case we want to create a non standard one.