title: Using custom Oid in Subject Alternative Name with Bouncycastle
body: <p>I am generating a certificate using BouncyCastle. Everything works fine until I am trying to add an Subject Alternative Name extension with GeneralName.OtherName an custom Oid=1.3.6.1.4.1.311.20.2.3 (it stands for User Principal Name (UPN)). So the result should be like:
  Subject Alternative Name section -> OtherName -> User Principal Name=user@domain</p>
  
  <p>I am doing it like this:</p>
  
  <pre><code>Asn1EncodableVector vector = new Asn1EncodableVector
  {
    new GeneralName(GeneralName.OtherName, 
                    new KeySpecificInfo(new DerObjectIdentifier("1.3.6.1.4.1.311.20.2.3"), new DerOctetString(GetBytes("user@domain"))))
  }
  DerSequence seq = new DerSequence(vector);
  GeneralNames subjectAltName = GeneralNames.GetInstance(seq);
  // Adding extension to X509V3CertificateGenerator
  certGen.AddExtension(X509Extensions.SubjectAlternativeName, false, subjectAltName);
  </code></pre>
  
  <p>And after it I receive a strange serialized result in the SubjectAlternativeName section of the created certificate. It is obvious that adding OtherName section is wrong, but I could not find any information about adding custom oid for BouncyCastle.
  Any ideas?</p>