I added an HTTPS connection using certificates to a program I'm working on.
It works fine, but I'm seeing one strange thing and wanted to post it
to the JavaRanch to see if anybody else has seen something like this or had any ideas on what I'm doing wrong.
I have two certificates - one good, one bad, and I added
Unit tests
for each condition. The thing that is odd, is that whenever I need to
'reset' the connection, it doesn't reset properly. If I put the
"Good" Certificate Test first then that passes and the "Bad" one fails
(it authenticates the certificate when it should throw an exception because it's a 'bad' certificate - it acts as if it's using the previous 'good' certificate).
If I put the "Bad" one first, the "Bad" one fails to authenticate (as expected) and then the good certificate test fails too but it should pass. I've checked my properties and it *looks* like they are being set when I print out their values, but it seems like it's not really over-riding properly on the second test.
Is there a Security Manager thing here at play and I'm not realizing
it. Are there problems in over-riding some of the properties?
I added code in both tests to close my connections, I null out the
variable pointing to my URL, and I call the garbage collector (I know
that doesn't mean it was *really* called, just requested) but I am clueless why it doesn't work.
Has anybody seen anything like this before?
It's not a big deal because I'll just turn off my 'bad certificate'
test, but I wanted to know if anybody knew why set-up only worked for
the first one.
Thanks in advance if you have any clues on this -
Greg Ostravich
=====
Here are some of my code-snippets if that helps, but they do work, just not in sequence one right after the other.
Settings for my keystore
fqp is a
string with a fully qualified path to my keystore.
I checked using File.exists() and it is there.
Here's the code snippet to open (and close) my connection and file stream to test that I authenticated correctly. I pass in the HTTPS url through hostCGIdev.