My favorites | Sign in
Google
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
          
New issue | Search
for
| Advanced search | Search tips
Issue 1016: Email app should allow connecting to servers with untrusted certificates
107 people starred this issue and may be notified of changes. Back to list
 
Reported by Xomenn, Oct 23, 2008
Android code version you are running:
I am using the shipping version that was distributed on my phone.1.0
TC4-RC19 109652 ota-rel-keys, release-keys

    Your development environment:
Windows Vista 64 bit

    Describe the problem:
My web server uses a CACert.org signed certificate. I cannot receive mail
from my server using ssl because the root cert is not trusted. But there no
way to override or add the cert to the trusted store.

    Additional information:

I was able to add the cert to the emulator and that made it trusted for the
web browser, but because there are not windows drivers available I cannot
try the same on the device.
Comment 1 by sjschultze, Oct 23, 2008
+1

Please fix.

Original reporter appears to know of some mechanism to add certs to the trusted store
(although he's not able to do so on Windows).  Can someone explain if it's
theoretically possible to do from other OS's?  Is this something that must be done
while in USB mode?
Comment 2 by sjschultze, Oct 23, 2008
Also, note:
http://forums.t-mobile.com/tmbl/board/message?board.id=87&message.id=6016

"1) The IMAP client refuses to connect to a server with a self-signed certificate.  I
run my own IMAP server on my home computer, and do not want to pay for a commercial
certificate.   This is likely a deal-breaker for me.  If I cannot resolve this issue,
the G1 will be returned."
Comment 3 by Xomenn, Oct 23, 2008
With the new windows drivers I tried to add the cert to the keystore. But it is read 
only because I dont have root access. So now what?
Comment 4 by youngdev, Oct 24, 2008
how do I add my server's cert to the keystore?  Is there documentation on this?
Comment 5 by Xomenn, Oct 24, 2008
These are the directions for the emulator (does not work on the actual device):
Download the Harmony JDK so you can edit bks keystores: http://harmony.apache.org/
Open up adb and start server.
Remount system partition rewrite.
Pull /system/etc/security/cacerts.bks 
use the keytool to add your root cert to the keystore. 
http://code.google.com/android/reference/org/apache/http/conn/ssl/SSLSocketFactory.ht
ml
password to keystore is default: changeit
Push keystore back to emulator
remount read only.

And you should be good. I can't test right now, so I am not 100% on those directions.
Again this does not work on the device because you do not have root access.

I do not quite know enough about writing applications for android to write one that 
will add a cert. I am planning but my hangup right now is how do I get enough 
permissions to remount the system partition. Any one have some info? There is a 
testing permission that sounds like it grants root. But I haven't tested or tried it 
yet.
Comment 6 by disconn3ct, Oct 25, 2008
The workaround is "ssl if available" (or "tls if available") - it won't ever check
the cert (so MITM is simple.. sigh) but it will use untrusted certs.

Don't worry tho, you aren't missing much. (The email app doesn't post changes to the
server..)
Comment 7 by sjschultze, Oct 25, 2008
Ha, you're right.  Switching it to "ssl if available" makes it use untrusted.
Comment 9 by Mike.Parkinson1, Oct 25, 2008
Is there a workaround for certificates when trying to connect to wifi? My work wifi
comes up with untrusted certificate(Cisco)and would normally prompt me for a connect
and password. I never get to that point on my G1. It will never let me enter the info
and gives me web page not available.
Comment 10 by xaos.mini, Oct 25, 2008
when i try ssl if available, it won't take my password. it just says "Username or
Password incorrect ()" I can connect with pop3, no ssl, after about three attempts,
the first and second attempts returning "no valid authentication method available".
The third attempt works and downloads mail. I'd rather have IMAP access though. There
should be an option to accept self-signed certs permanently.
Comment 11 by Xomenn, Oct 25, 2008
SSL if avaliable does work, but what use is imap if it doesnt update the server?

At least I can view now.

Is it not updating the server a mail app thing or because of the certificates?

Thanks for the work around.
Comment 12 by xaos.mini, Oct 28, 2008
i might also add that if you have special characters in your password you will get
the message "Username or password incorrect. ()" as well. the mail app apparently
does not process special characters correctly.
Comment 13 by michael573114, Oct 29, 2008
The "if availble" option works for IMAP, if you're okay with the main-in-the-middle
attack issue.  I control the server, so I'd know in either case, I'm not too
concerned here.

"SSL/TLS if available" does NOT work for SMTP if your server *requires* TLS/SSL to
send mail.  Mine does.  Without using TLS/SSL, it thinks I'm trying to illegally
relay through the SMTP server, and rejects me.

I really need this fixed....
Comment 14 by dc.disconnect, Nov 04, 2008
@michael573114 
just fyi, "I control the server" doesn't protect you against MITM.  If I sit at a
gateway (say, your local starbucks) I can hand you any cert I want. The g1 will
happily (and silently) accept it, and provide me with your login credentials. If I'm
really sneaky, I'll proxy a connection back to the mailserver and provide you with
your mail and you won't even know it happened..

Thats the big problem with it not verifying untrusted certs - it will accept any
cert, not just the one you explicitly trusted.

It needs to behave more like ssh ("I have a cert, it is Foo, do you trust it
forever?" .. "Hey, this cert is no longer Foo! Bad Bad!")..

Comment 16 by michael573114, Nov 04, 2008
Oh right, I didn't really mean it that way, I was thinking of when the server was
compromised more than MitM attacks, but now that I read what I said, I realize that
wasn't really clear at all :)  Both the server being compromised and a proxy along
the way are certainly quite possible without proper certificate checking.

I got poking around in the source for the mail client (actually K9, but whatever,
same thing), and it looks to me like this is best fixed by having some sort of
facility to install certificates into the system keyring (or whatever it uses). 
Doing it in the mail client alone means that the mail client needs to have some kind
of key store itself, and the libraries used for doing SSL stuff don't look like they
support anything like that.


Comment 17 by Xomenn, Nov 07, 2008
Good news, now that we have root access you can edit the file in my previous
directions :).......search the internet for g1 root access.
Comment 18 by lucas.silacci, Nov 08, 2008
+1

Sucks to have the hack the phone the first day I have it. :-)

I've configured my mail server to only accept SSL connections so "TLS if available"
will not work for me.
Comment 19 by HighlandSun, Nov 09, 2008
Yes, the keystore password for cacerts.bks is "changeit". The harmony JDK's keytool
didn't work for me. I had to use the Sun JDK1.6 keytool, and I had to install the
BouncyCastle jar file from here
http://bouncycastle.org/latest_releases.html

http://bouncycastle.org/download/bcprov-jdk16-141.jar

into my JRE. Then I ran this command to add a CAcert to cacerts.bks:
  keytool -keystore cacerts.bks -storetype BKS -provider
org.bouncycastle.jce.provider.BouncyCastleProvider -storepass changeit -import -v
-trustcacerts -alias Symas -file Symas.pem

and answered "yes" to the prompt.

Now my pop3 account works.

Comment 20 by Xomenn, Nov 10, 2008
Btw, update RC30 removes the root, so do this before you upgrade.
Comment 21 by dereks443, Dec 03, 2008
The suggested fix above, to set "TLS if available", is ambiguous.

It does not state whether the "if available" setting will use TLS with an untrusted
cert, or whether it simply skips using TLS altogether (and thus transmits my email
password in plaintext across the Internet).

TLS needs to be fixed to allow private certs.  This is a critical issue, from where
I'm standing.

Comment 22 by michael573114, Dec 03, 2008
I've tested it - this setting means that it will prefer plaintext if TLS is not
available - definitely not desirable.

Note that a fix for this (and many other things) was implemented in k9mail:
http://code.google.com/p/k9mail
Comment 23 by praeluceo, Dec 11, 2008
This really should be a default configuration option, the firmware needs to support 
adding certificates into the store without needing to "root" your phone.  I'm 
confirming that this is a bug and I would love to see it fixed in a future OTA 
release since the previous OTA update killed my ability to add certificates to my 
phone.
Comment 24 by jbq@google.com, Feb 09, 2009
(No comment was entered for this change.)
Labels: -Type-Defect Type-Enhancement
Comment 25 by duane.obrien, Apr 10, 2009
Any update to this?  Work uses Direct Push w/ Self Signed Cert, and I could use this
to get an alternative client working.
Comment 26 by yousef.alhashemi, Jun 05, 2009
I'm tired of waiting for a fix. The original report (by Xomenn) was posted more than
7 months ago. Why is this problem being ignored? I'm now considering buying a
certificate (as opposed to using a self-signed one). But then, where do I find a list
of authorities that android recognizes?
Comment 27 by tamplinjohn, Jun 06, 2009
Just do like I did -- give up and switch to K9 instead.

It is open source and was derived from the IMAP client included in Android, so you
would think it would be easy enough to backport support from it.
Comment 28 by Xomenn, Jun 06, 2009
yousef.alhashemi are you using a root version of the OS? or willing to, if so I can
help with adding your self signed cert to the system repository.  Otherwise I would
recommend using K9. Google will fix this when they feel like it and there has only
been 28 comments in 7 months so I doubt it will make much of a priority.
Comment 29 by Xomenn, Jun 06, 2009
They have not even marked it as reviewed.
Comment 30 by marcus.redivo, Jun 08, 2009
The Android phone has arrived in Canada, and I just got back from going to buy one.
My first question: "CAN I IMPORT MY COMPANY'S ROOT CA CERTIFICATE?"

On testing, it turns out the answer is "NO". As this means I cannot check my email
with it, I left without a new phone.

This needs to get fixed. I can understand why importing random root CA certificates
off the web is a bad idea (phishing), but some way of deliberately importing one is
required. This is accepted practice for corporate desktop roll-outs; mobile devices
are the next wave.
Comment 31 by duane.obrien, Jun 08, 2009
I went with the Touchdown client from the Marketplace to get around this problem, and
have been really happy with the results.
Comment 32 by mark.lise, Jun 09, 2009
*bump*  I too self-sign my mail server and it would be nice not to use the "ssl if
available" workaround.  I'd rather force SSL and have it fail rather than attempting
to send my password over the standard channel.
Comment 33 by FuzzyCat, Jul 31, 2009
*bump*

Really want to see this fixed - I want to import self signed certs so I can test my
applications. Why is this such an issue? We have a keystore, why can't we have access
to it?


Comment 34 by timriker, Aug 20, 2009
If you have root access, you can do something like this:

# get the cacert root certificate
wget -N http://www.cacert.org/certs/root.crt

# get the BouncyCastle support jar
wget -N http://bouncycastle.org/download/bcprov-jdk16-141.jar

# install the jar, on my debian box that's this:
sudo mv bcprov-jdk16-141.jar /usr/lib/jvm/java-6-sun-1.6.0.14/jre/lib/ext/

# read the existing cacerts.bks off your phone
adb pull /system/etc/security/cacerts.bks cacerts.bks

# add the cacert as a trusted ca
keytool -keystore cacerts.bks -storetype BKS -provider
org.bouncycastle.jce.provider.BouncyCastleProvider -storepass changeit -trustcacerts
-alias CACERT -file root.crt

# test that it worked. :)
keytool -keystore cacerts.bks -storetype BKS -provider
org.bouncycastle.jce.provider.BouncyCastleProvider -storepass changeit -v -list| grep
-i cacert

# remount /system read-write
adp shell mount -o remount,rw /system

# upload the new certs file
adb push cacerts.bks /system/etc/security/

# remount /system read-only
adp shell mount -o remount,ro /system


I'll attach a modified cacerts.bks here in case you want to just upload mine with the
last 3 steps. I recommend you repeat the steps instead of trusting mine. :) Never the
less, I'll attach it. md5sum info:

7ab03d8cc400d1db01b0b0b22b539073  cacerts.bks

Note: placing this file in your build tree should include it in your built images.
I've not tried this yet, but it would go here:

dalvik/libcore/security/src/main/files/cacerts.bks
cacerts.bks
52.5 KB   Download
Comment 35 by koshatul, Aug 20, 2009
But getting root access on a Magic isn't an option, without the dev phone it's
irreversible and quite likely to break.

Is there some way to work around this and modify the keystore on a non-rooted magic
(or G1) ?
Comment 36 by Xomenn, Aug 20, 2009
Nope, each application can have there own keystore that can be customized but 
without root or OS support for changes there is no way to manage the certificates.

Everyone agree?
Comment 37 by william.furr, Aug 20, 2009
Sure you can root a HTC Magic:  http://android-dls.com/wiki/index.php?title=Magic_Rooting
Comment 38 by ringerc, Aug 21, 2009
Even sony ericsson phones support import of a CA certificate. So do Symbian S60 and
Windows Mobile. They do so because this is a feature _people_ _need_. Many business
mail systems have self-signed or private CA-derived certificates not only for mail
but also often for private intranets.

In addition to lacking support for importing CA certs, Android appears to lack any
facility for importing a PKCS#12 client certificate or specifying a .p12 file when
performing SSL/TLS negotiation against a server.

http://code.google.com/p/android/issues/detail?id=3620
Comment 39 by jonabdn, Aug 24, 2009
Hi,

I need to create a keystore into the android phone with server certificate and 
user's private key. Any idea? Also I need PKCS#11 but I don't know how do it.

Thanks
Comment 40 by jbq@google.com, Aug 24, 2009
(No comment was entered for this change.)
Labels: Component-Applications
Comment 41 by Xomenn, Aug 24, 2009
The last post couple posts were application related, but the issue is not. We need OS 
Support for third party certificates.
Comment 42 by jbq@google.com, Aug 27, 2009
(No comment was entered for this change.)
Summary: Email app should allow connecting to servers with untrusted certificates
Labels: Subcomponent-Email
Comment 43 by jbq@google.com, Aug 27, 2009
 Issue 1077  has been merged into this issue.
Comment 44 by jbq@google.com, Aug 27, 2009
 Issue 3237  has been merged into this issue.
Comment 45 by jbq@google.com, Aug 27, 2009
Issue 3620 has been merged into this issue.
Comment 46 by ringerc, Aug 27, 2009
Issue 3620 was incorrectly merged into issue 1016.

3620 is about X.509 *CLIENT* certificates, which contain *PRIVATE* keys that are used
by the client to authenticate its self to the server for bi-directional SSL
authentication. They are not the same thing as the CA certificates (which contain
public keys) referred to by 1016, Client certificate support is not the same as
support for adding CA certificates.

Both do require a user-updatable certificate store to be effective, but use of client
certificates also requires support in the SSL/TLS libraries to notice a client cert
request from the server during negotiation and look up the appropriate certificate,
possibly prompting the user for the cert's passphrase if it's stored encrypted in the
phone keystore.
Comment 47 by devilcoffee, Sep 17, 2009
I am not sure if this related, but sources indicate that it is. This T-Mobile Forums 
thread shows what happens when I try to send email from my MyTouch 3G with either 
k9mail or the default email application. I have tried the "SSL/TLS if Available" to 
no avail. It also appears that the mail applications are not using AUTH PLAIN too.

http://forums.t-mobile.com/tmbl/board/message?
board.id=AndroidAppHelp&message.id=5507#M5507

(While the logs show an invalid password, the password is *NOT* incorrect, and that 
has been verified countless times. I can use the exact same credentials to 
authenticate SMTP from any other MUA.)
Comment 48 by laurent198, Oct 27, 2009
A kind of same problem on webpage...

When i try to access in the intranet of my company. On a computer, the page ask me to
accept the certificate, when is done i sould enter my username and password.
On the web browser of android, i have a message about the certificate: view,
continue, leave. I select continue and i have a error 401.

Thanks
Comment 49 by jirkaprachar, Oct 31, 2009
We NEED Support for third party CA certificates!!!
Comment 50 by kestracuew, Nov 09, 2009
Agreed.  On the Droid it allows me to import a certificate, but then asks for a
password.  There IS no password.  I really don't want to have to go back to the
iPhone at this point.
Comment 51 by eimann, Nov 09, 2009
Try 'changeme' as Keystore password
Comment 52 by kestracuew, Nov 09, 2009
Thanks eimann, tried that but no good.  
Comment 53 by rm.rf.dotstar, Nov 09, 2009
Where did you go on the Droid to import the cert?  I put it on a webserver and pulled
it up that way.  Seemed to import it, but the mail client obviously wasn't using it.
Comment 54 by kestracuew, Nov 09, 2009
Settings->location and security->Install from SD card
Comment 55 by kestracuew, Nov 10, 2009
By the way, guys.  This isn't really an enhancement since neither "SSL accept all
certificates" nor importing a certificate work as they should.
Comment 56 by slavelle85, Nov 24, 2009
Using Motorola Droid from Verizon and Ive run into all the problems I've seen others 
reporting - just when you think it's going to work by importing a properly 
exported .p12 certificate from SD, it goes into the password not correct nonsense, 
which of course makes it impossible to import the cert.  

Everything about my sync with Exchange (2007) works except the ability to get 
attachments.  SSL is required, so there is no "turn it off to get attachments" 
choice for me.

I recall having an issue with a client a while back where they had gotten Blackjack 
Windows mobile devices.  With previous windows mobile devices, you could import a 
cert, but not with those - the client HAD to get a Thawte (or similar) certificate 
or they were just out of luck.

Please fix this, Google.  You've got SO many cool things going for your stuff and 
little misses like this keep some filks from taking the device seriously.  I know 
that there is an interest in Google promoting their own mail solutions, even to 
corporate, but not fixing what seems like such a simple thing doesn't seem a good 
way to try to attract that audience.
Comment 57 by mehmeton...@gmail.com, Dec 01, 2009
I am using the European version of Droid "Milestone". I have the same problem.
I downloaded the .p12 certificate in Sd card but it requires a password, which i dont
have any clue about it.

Comment 58 by LatinSuD, Dec 22, 2009
The "bouncycastle" method worked for me for https, but when it comes to SMTP (either
SSL or TLS) with K-9 it didn't.
I think it's because my hosting server shares certificate with others and uses a
wildcard in name, like "*.serversite.com". Could it be because of that?
Comment 59 by shukla.amrendra, Jan 05, 2010
I am uploading certificates in
/root/myandroid/dalvik/libcore/security/src/main/files/cacerts directory. Please find
the listing 
:~/myandroid/dalvik/libcore/security/src/main/files/cacerts# ls
class3.crt  root.crt

After building filesystem, when i am running it, I am getting following errors
E/keystore( 2328): Can not initialize the keystore, the directory exist?
E/        ( 2329): Can not open/create the keystore directory /data/misc/keystore/
E/keystore( 2329): Can not initialize the keystore, the directory exist?

I think certimport.sh script is not working properly, and is not creating cacerts.bks 
~/myandroid/dalvik/libcore/security/src/main/files# ls
cacerts  cacerts.bks  certimport.sh


certimport.sh
637 bytes   Download
Comment 60 by LatinSuD, Jan 05, 2010
I don't understand that script, it seems to delete the certificate store at first!
Are you sure you can trust that script?
Comment 61 by shukla.amrendra, Jan 05, 2010
This is the correct script but my keytool is not supporting -providerpath option. I
am getting error
Illegal option:  -providerpath
keytool usage:

certimportJ
1.3 KB   Download
Comment 62 by shukla.amrendra, Jan 05, 2010
Can you help me how to install correct keytool, that supports all the option required
to create .bks store.?
Comment 63 by shukla.amrendra, Jan 05, 2010
# keytool -keystore cacerts.bks -storetype BKS -provider
org.bouncycastle.jce.provider.BouncyCastleProvider -storepass changeit -import
-trustcacerts -alias CACERT -file root.crt
keytool error: java.lang.ClassNotFoundException:
org.bouncycastle.jce.provider.BouncyCastleProvider

Comment 64 by marcus.redivo, Jan 20, 2010
My hTc Magic seems to have been silently updated on January 15, and I can no longer
send or receive mail through my SSL-required mail server. Without mail, my phone may
as well be a brick. An $85/month brick.

I tried to import the company root CA certificate that signed the mail server
certificate by downloading it in the Android browser. This resulted in the following
message:

----------------
<Unknown>
www.site.tld
Cannot download. The content is not supported on the phone.
----------------

As has been pointed out more than once earlier in this thread, not supporting SSL
mailserver access makes Android pretty well useless in corporate environments.

Can we please get a higher priority for this issue? Thanks.
Sign in to add a comment