如何从PHP发送crt文件?

When I directly access to http://example.com/mycertificate.crt, it's well recognized and installed as a certificate.
Now, when I just access to http://example.com, my index.php seems not send it correctly.
My remote device download the file as I can see it but when I click on it, it says it cannot install it because the file is not readable. What's wrong?

Edit Below I modified my code removing html tags, but I still see few non printable characters at the begining and at the end of my certificate.

<?php
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'android') !== false) {
        if (file_exists('./mycertificate.crt')) {
            header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
            header("Content-Type: application/x-x509-ca-cert");
            header("Content-Transfer-Encoding: Binary");
            header("Content-Length:".filesize('./mycertificate.crt'));
            header("Content-Disposition: attachment; filename=mycertificate.crt");
            readfile('./mycertificate.crt');
        } else {
            die('ERROR');
        }
    } else {
        die('Bad device');
    }
 ?>