title: Getting Subject Alternate Names with Pkcs10CertificationRequest
body: <p>I'm currently able to decode a CSR's values except for Requested Extensions, specifically <code>X509v3 Subject Alternative Name</code>. Here's the relevant part of 
   my `DecodeCSR(string csr):</p>
  
  <pre><code>public void DecodeCsr(string csrStr){
  //getting just csr
  var csrChars = Regex.Replace(csrStr, @"-----[^-]+-----", "").Trim().Replace(" ", "").Replace(Environment.NewLine, "").ToCharArray();
  //converting that string into a byte array
  byte[] csrEncode = Convert.FromBase64CharArray(csrChars, 0, csrChars.Length);
  //giving decodeCsr the byte array
  Pkcs10CertificationRequest decodeCsr = new Pkcs10CertificationRequest(csrEncode);
  //getting a string of subject information
  string subject = decodeCsr.GetCertificationRequestInfo().Subject.ToString();
  //here's how I'm getting a DerSet of attribute
  DerSet atts = (DerSet)decodeCsr.GetCertificationRequestInfo().Attributes;
  }
  </code></pre>
  
  <p>Here's a test csr with SANs:  </p>
  
  <pre><code>string csr = "-----BEGIN CERTIFICATE REQUEST-----MIIC1DCCAbwCAQAwXjELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB0dlb3JnaWExEDAOBgNVBAcMB0F0bGFudGExDTALBgNVBAoMBFRlc3QxHDAaBgNVBAMME3d3dy50aGlzaXNhdGVzdC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDFU4pXLB3d8csjvRIkIdZfUF2m9sijtk1bqYohqVwYr3+OyDRkfRuTCni8RJS9VOcl6n5aUiK27P4s5j9LqqfL0vS8B949P/ewb2ip2BGB1sEmxKcsEoZYNNEhMm9p7yNTAEqJ/WN0N1CpKBFV1J/w6xiQy5tUyUe7C9c8DX6K1uhEDF9pfeTaCNxYBShm0JFuAIqn6Z+RzbC7tdwc0KgN/bhx3bEvg8b0p/hgxd2veuUmB/fcIPsFawkGFPcQzLpSbc1Vb+zru40HAbRflyQckA3ZgRsa1OHsdiOyb8vpV7dUm4VHOm38bw2wVImRMfRtNZXrL/WiWcGadtFV8nxXAgMBAAGgMTAvBgkqhkiG9w0BCQ4xIjAgMB4GA1UdEQQXMBWCCHRlc3QuY29tggl0ZXN0Mi5jb20wDQYJKoZIhvcNAQELBQADggEBAKXxHlruiqtTwB1Ov17K+mz03EidfecdW+9u8gcLdOOLKn5kCg6RuC0mCjGHvFGjE6ljFc5cyUFbfdqzd8QXh1f3AgxveR+oq1wExJNr0Yl6kjVEdtndvHhSzUmZZ02EcPbIq/eY5KSTdKidjvIJMwTUtIyUQ71y/vSVn0YavvXYo/re57kC7chW/Ns/hZmHrZ6GvMWE9ea3P3jOKPyXCULJlbQCjXc6CQJAkBlcKpvnW6kU2PjreDWzRMhzqZzUqhc6RsGzz84/xwBsrYXfTj91FQd9+w15CYzBEJOv/Iz3CfVGb4s1+yUPVxgei2ezTjfQVcQgq4CusRnDU5/7lmE=-----END CERTIFICATE REQUEST-----";
  </code></pre>
  
  <p>The information I can get from <code>decodeCsr.GetCertificationRequestInfo().Attributes</code> is an <code>Org.BouncyCastle.Asn1.DerSet</code> that looks like this:</p>
  
  <pre><code>DerSet atts = (DerSet)decodeCsr.GetCertificationRequestInfo().Attributes;
  </code></pre>
  
  <p>This is what it looks like in debug mode(a picture of the overal object is below): </p>
  
  <pre><code>atts    {[[1.2.840.113549.1.9.14, [[[2.5.29.17, #3026820a61757374696e2e636f6d820b61757374696e322e636f6d820b61757374696e342e636f6d]]]]]} Org.BouncyCastle.Asn1.DerSet
  </code></pre>
  
  <p><a href="https://i.imgur.com/cD2dIyM.png" rel="nofollow noreferrer">I can see the <code>DerOctetString</code> in debug mode</a>, however I have no idea how to get to it. I believe if i can get that far Hugo's answer may be applicable, there is a <code>DerOctetStringParser</code> but at the moment I have nothing to give it. </p>
  
  <p>I've tried to treat <code>atts</code> as a string removed the OIDs get the value exactly like the <code>DerOctetString</code> in debug mode and cast it as a <code>DerOctetString</code> that didn't work, and I don't believe that answer scales well. </p>