Solved

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

Posted on 2004-04-13
9
181 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

777 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