title: Save BIO into char* (from SMIME_write_CMS)
body: <p>I want to save (pipe/copy) a BIO into a char array.
  When I know the size it works, but otherwise not.</p>
  
  <p>For example, I can store the content of my char* into a BIO using this</p>
  
  <pre><code>const unsigned char* data = ...    
  myBio = BIO_new_mem_buf((void*)data, strlen(data));
  </code></pre>
  
  <p>But when I try to use SMIME_write_CMS which takes a BIO (what I've created before) for the output it doesn't work.</p>
  
  <pre><code>const int SIZE = 50000;
  unsigned char *temp = malloc(SIZE);
  memset(temp, 0, SIZE);
  
  out = BIO_new_mem_buf((void*)temp, SIZE);
  if (!out) {
      NSLog(@"Couldn't create new file!");
      assert(false);
  }
  
  
  int finished = SMIME_write_CMS(out, cms, in, flags);
  if (!finished) {
      NSLog(@"SMIME write CMS didn't succeed!");
      assert(false);
  }
  
  printf("cms encrypted: %s\n", temp);
  
  NSLog(@"All succeeded!");
  </code></pre>
  
  <p>The OpenSSL reference uses a direct file output with the BIO.
  This works but I can't use BIO_new_file() in objective-c... :-/</p>
  
  <pre><code>out = BIO_new_file("smencr.txt", "w");
  if (!out)
      goto err;
  
  /* Write out S/MIME message */
  if (!SMIME_write_CMS(out, cms, in, flags))
      goto err;
  </code></pre>
  
  <p>Do you guys have any suggestion?</p>