Solved

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

Posted on 2004-04-13
9
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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…
Introduction to Processes

623 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