Solved

PHP - !! HELP URGENT !! using php to upload user certificates

Posted on 2004-04-13
9
178 Views
Last Modified: 2010-04-17
i'm going crazy over this - here is the code i'm using  - SOME1 PLEASE TELL ME WHAT I'M DOING WRONG
I'M GIVING ALL MY POINTS ( I REALLY REALLY NEED A SOLUTION ... FAST!)

######################################################
function upload($filename, $content_type="application/x-x509-ca-cert") {
      header("Pragma: public");
      header("Expires: 0");
      header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0");
      header("Content-type: $content_type");
      header("Content-length: ".strlen($filename)."\"");
      header("Content-Disposition: filename=$filename");
      readfile("$filename");
      exit();
}

upload("cacert.crt");
######################################################

i keep getting this error -

-------------------------------------------------------------------------------------------------
Microsoft Internet Explorer
------------------------------
Internet Explorer cannot download test.php from localhost.
Internet Explorer was not able to open this Internet site.
The requested site is either unavailable or cannot be found.  Please try again later.
-------------------------------------------------------------------------------------------------

I dont understand why i'm download the file "test.php" instead of the ca-certificate

I'm running - Apache/2.0.48 (Win32) -- PHP/4.3.4 -- mod_ssl/2.0.46 -- OpenSSL/0.9.7b

Vamsi
0
Comment
Question by:vamsi_k03
  • 5
  • 4
9 Comments
 

Expert Comment

by:NorbertG
ID: 10822611
Hello Vamsi,

are you trying to upload (from PC to server) or to download (from server to PC) the data?

The follwoing changes are suggested for download

old :  header("Content-type: $content_type");
new: header("Content-type: $content_type name=$filename");

old :header("Content-Disposition: filename=$filename");
new: header("Content-Disposition: attachment; filename=$filename");
0
 

Author Comment

by:vamsi_k03
ID: 10823367
Hello Norbert,

i'm downloading from server to client. on the client i'm using IE6 win2000
i've already tried the suggestions u gave, actually for IE6 nothing happens if i add the word "attachment" in Content-Disposition header. i get a download window, but i eventually get the same error.

any other suggestions?

actually something very wierd happens - internet explorer keeps trying to get me to dowload the "test.php" file itself. but if i try to download say an mp3 file or a zip file, it lets me download the correct file. this is why i think it has something to do with the apache server setting and of the MIME type.

bye,
vamsi
0
 

Expert Comment

by:NorbertG
ID: 10831665
Hi Vamsi,

2 questions:

a) have you checked that you can access "cacert.crt" from your script?
    $data = file("cacert.crt");
    foreach ($date as $ln => $line) echo $line;

b) is your script running native or in a session environment?

regards
   ng
0
 

Author Comment

by:vamsi_k03
ID: 10831719
Hi Norbert,

yes i already tried access to file. it shows me the certificate. i even checked with openssl to see if the certificate is in proper format. i converted to "DER" format and i tried with that. no luck

script is not running in a session. i showed the whole script, there is nothing more.

this is very frustrating.

vamsi
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Expert Comment

by:NorbertG
ID: 10839788
Could you post the information contained in conf/mime.types from your apache system?
0
 

Author Comment

by:vamsi_k03
ID: 10841622
Hi Norbert,
i'm sorry i didn't undertand your question before. the script IS running in session environment. what does thsi mean?
do you have a solution in mind?

bye
vamsi
0
 

Author Comment

by:vamsi_k03
ID: 10841815
NG, if you thinks you know how i can install a user certificate or a ca certificate without the user downloading it to the hard drive, please let me know. i do not want the certificate to be stored on the local harddrive.

here is the mime.types - i'm showing the certificate stuff -
--------------------------------------------------
application/x-x509-ca-cert      der pem crt
application/x-pkcs12            p12 pfx
application/x-pkcs7-crl            crl
--------------------------------------------------

thank you
vamsi
0
 

Accepted Solution

by:
NorbertG earned 380 total points
ID: 10842326
Vamsi, (in reply to your 05:40AM message)

if the script is running in a session, you should add
session_cache_limiter('public');   BEFORE session_start();
for further information check http://php3.de/manual/en/function.session-cache-limiter.php
0
 

Author Comment

by:vamsi_k03
ID: 10848913
hi norbert,

thanks for all the time you spent on trying to answer this question.
i tried what you said, but that didn't work. but it will be very helpful later on

i've given up on this. thanks again for your help

vamsi
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now