value=(p1) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
static VALUE
ossl_x509attr_set_value(VALUE self, VALUE value)
    X509_ATTRIBUTE *attr;
    VALUE asn1_value;
    int i, asn1_tag;

    OSSL_Check_Kind(value, cASN1Data);
    asn1_tag = NUM2INT(rb_attr_get(value, rb_intern("@tag")));
    asn1_value = rb_attr_get(value, rb_intern("@value"));
    if (asn1_tag != V_ASN1_SET)
        ossl_raise(eASN1Error, "argument must be ASN1::Set");
    if (!RB_TYPE_P(asn1_value, T_ARRAY))
        ossl_raise(eASN1Error, "ASN1::Set has non-array value");

    GetX509Attr(self, attr);
    if (X509_ATTRIBUTE_count(attr)) { /* populated, reset first */
        ASN1_OBJECT *obj = X509_ATTRIBUTE_get0_object(attr);
        X509_ATTRIBUTE *new_attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, 0, NULL, -1);
        if (!new_attr)
            ossl_raise(eX509AttrError, NULL);
        SetX509Attr(self, new_attr);
        attr = new_attr;

    for (i = 0; i < RARRAY_LEN(asn1_value); i++) {
        ASN1_TYPE *a1type = ossl_asn1_get_asn1type(RARRAY_AREF(asn1_value, i));
        if (!X509_ATTRIBUTE_set1_data(attr, ASN1_TYPE_get(a1type),
                                      a1type->value.ptr, -1)) {
            ossl_raise(eX509AttrError, NULL);

    return value;
Register or log in to add new notes.