Solved

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

Posted on 2004-04-13
9
183 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

839 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