web_modules/forge.bundle.js
function _dnToAsn1(obj) {
  // create an empty RDNSequence
  var rval = asn1.create(
    asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);

  // iterate over attributes
  var attr, set;
  var attrs = obj.attributes;
  for(var i = 0; i < attrs.length; ++i) {
    attr = attrs[i];
    var value = attr.value;

    // reuse tag class for attribute value if available
    var valueTagClass = asn1.Type.PRINTABLESTRING;
    if('valueTagClass' in attr) {
      valueTagClass = attr.valueTagClass;

      if(valueTagClass === asn1.Type.UTF8) {
        value = forge.util.encodeUtf8(value);
      }
      // FIXME: handle more encodings
    }

    // create a RelativeDistinguishedName set
    // each value in the set is an AttributeTypeAndValue first
    // containing the type (an OID) and second the value
    set = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
        // AttributeType
        asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
          asn1.oidToDer(attr.type).getBytes()),
        // AttributeValue
        asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)
      ])
    ]);
    rval.value.push(set);
  }

  return rval;
}
function _dnToAsn1(obj) {
  // create an empty RDNSequence
  var rval = asn1.create(
    asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);

  // iterate over attributes
  var attr, set;
  var attrs = obj.attributes;
  for(var i = 0; i < attrs.length; ++i) {
    attr = attrs[i];
    var value = attr.value;

    // reuse tag class for attribute value if available
    var valueTagClass = asn1.Type.PRINTABLESTRING;
    if('valueTagClass' in attr) {
      valueTagClass = attr.valueTagClass;

      if(valueTagClass === asn1.Type.UTF8) {
        value = forge.util.encodeUtf8(value);
      }
      // FIXME: handle more encodings
    }

    // create a RelativeDistinguishedName set
    // each value in the set is an AttributeTypeAndValue first
    // containing the type (an OID) and second the value
    set = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
        // AttributeType
        asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
          asn1.oidToDer(attr.type).getBytes()),
        // AttributeValue
        asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)
      ])
    ]);
    rval.value.push(set);
  }

  return rval;
}
function _dnToAsn1 ( obj ) { // create an empty RDNSequence
 var rval = asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . SEQUENCE , true , [ ] ) ; // iterate over attributes
 var attr , set ; var attrs = obj . attributes ; for ( var i = 0 ; i < attrs . length ; ++ i ) { attr = attrs [ i ] ; var value = attr . value ; // reuse tag class for attribute value if available
 var valueTagClass = asn1 . Type . PRINTABLESTRING ; if ( 'valueTagClass' in attr ) { valueTagClass = attr . valueTagClass ; if ( valueTagClass === asn1 . Type . UTF8 ) { value = forge . util . encodeUtf8 ( value ) ; } // FIXME: handle more encodings
 } // create a RelativeDistinguishedName set
 // each value in the set is an AttributeTypeAndValue first
 // containing the type (an OID) and second the value
 set = asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . SET , true , [ asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . SEQUENCE , true , [ // AttributeType
 asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . OID , false , asn1 . oidToDer ( attr . type ) . getBytes ( ) ) , // AttributeValue
 asn1 . create ( asn1 . Class . UNIVERSAL , valueTagClass , false , value ) ] ) ] ) ; rval . value . push ( set ) ; } return rval ; }
Converts an X.509 subject or issuer to an ASN.1 RDNSequence.

@param obj the subject or issuer (distinguished name).

@return the ASN.1 RDNSequence.
Converts an X . 509 subject or issuer to an ASN . 1 RDNSequence .