Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-13
9
Medium Priority
?
195 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 

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 1140 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Starting up a Project

670 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