php - AS2Secure drops multipart/signed content-type from headers -


i'm trying received as2 mdn using php lib as2secure. message arrives , decodes fine, when response goes out strips main "multipart/signed" value content-type.

for instance, should in main header designate multipart message:

content-type: multipart/signed; boundary="----=_part_8f23d0b4-8a42-4946-9928-4d12d9f7fc66.63"; protocol="application/pkcs7-signature"; micalg=sha1 

however, when response multipart message goes out, see in main headers:

content-type: text/html; charset=utf-8 

this triggers error in remote server, expects message designate content-type multipart.

i tracked stripping of multipart content-type down code in as2mdn.php:

// todo : replace futur as2mimepart separate content header if (strpos($content, "\n\n") !== false) $content = substr($content, strpos($content, "\n\n") + 2); 

if remove code, missing content-type: multipart/signed line shows in body content-type: text/html still shows in headers.

any ideas?

this caused php laravel framework (which handles app's routing) overwriting headers during output.

changing code in handle() method in as2server.php:

ob_end_clean(); // send headers foreach ($mdn->getheaders() $key => $value) {     $header = str_replace(["\r", "\n", "\r\n"], '', $key . ': ' . $value);     header($header); }  // output mdn echo $mdn->getcontent(); 

...to laravel friendly code:

$headers = [];  foreach ($mdn->getheaders() $key => $value) {     $headers[str_replace(["\r", "\n", "\r\n"], '', $key)] = str_replace(["\r", "\n", "\r\n"], '', $value); }  return \response::make($mdn->getcontent(), 200, $headers); // use native laravel response. 

...solved problem!


Comments