title: parsing certificate using openssl/x509.h
body: <p>i am using #import  class to parse the certificate and to get the expire date and start date am using the following function </p>
  
  <pre><code>static NSDate *CertificateGetExpiryDate(X509 *certificateX509)
  {
      NSDate *expiryDate = nil;
  
      if (certificateX509 != NULL) {
          ASN1_TIME *certificateExpiryASN1 = X509_get_notAfter(certificateX509);
          if (certificateExpiryASN1 != NULL) {
              ASN1_GENERALIZEDTIME *certificateExpiryASN1Generalized = ASN1_TIME_to_generalizedtime(certificateExpiryASN1, NULL);
              if (certificateExpiryASN1Generalized != NULL) {
                  unsigned char *certificateExpiryData = ASN1_STRING_data(certificateExpiryASN1Generalized);
  
                  // ASN1 generalized times look like this: "20131114230046Z"
                  //                                format:  YYYYMMDDHHMMSS
                  //                               indices:  01234567890123
                  //                                                   1111
                  // There are other formats (e.g. specifying partial seconds or
                  // time zones) but this is good enough for our purposes since
                  // we only use the date and not the time.
                  //
                  // (Source: http://www.obj-sys.com/asn1tutorial/node14.html)
  
                  NSString *expiryTimeStr = [NSString stringWithUTF8String:(char *)certificateExpiryData];
                  NSDateComponents *expiryDateComponents = [[NSDateComponents alloc] init];
  
                  expiryDateComponents.year   = [[expiryTimeStr substringWithRange:NSMakeRange(0, 4)] intValue];
                  expiryDateComponents.month  = [[expiryTimeStr substringWithRange:NSMakeRange(4, 2)] intValue];
                  expiryDateComponents.day    = [[expiryTimeStr substringWithRange:NSMakeRange(6, 2)] intValue];
                  expiryDateComponents.hour   = [[expiryTimeStr substringWithRange:NSMakeRange(8, 2)] intValue];
                  expiryDateComponents.minute = [[expiryTimeStr substringWithRange:NSMakeRange(10, 2)] intValue];
                  expiryDateComponents.second = [[expiryTimeStr substringWithRange:NSMakeRange(12, 2)] intValue];
  
                  NSCalendar *calendar = [NSCalendar currentCalendar];
                  expiryDate = [calendar dateFromComponents:expiryDateComponents];
  
                  [expiryDateComponents release];
              }
          }
      }
  
      return expiryDate;
  }
  </code></pre>
  
  <p>but i want to parser the entire details of the certificate like common name , version , private key etc.</p>
  
  <p>can any on please tell me how can i get that thing</p>
  
  <p>X509_NAME *issuerX509Name = X509_get_issuer_name(certificateX509);
   X509_NAME *subjectX509Name = X509_get_subject_name(certificateX509);</p>
  
  <p>with the above two functions i am getting the issue name and subject but i want to convert this thing to Nsstring format .</p>
  
  <p>can any one please help me how can i convert X509_NAme to Nsstring sing for my next request i have to append these names to my request.</p>
  
  <p>Thanks in advance</p>