SunPKCS11 doesn't work as default keystore provider for SSL connections

Hi all,
I'm experiencing a problem using SunPKCS11 as a keystore provider for SSL.
Below the code that doesn't work as expected:
String pkcs11config = "name = " + "bit4id" + "\nlibrary = " + "c:/windows/system32/bit4p11.dll";
byte[] pkcs11configBytes = pkcs11config.getBytes();
ByteArrayInputStream configStream = new ByteArrayInputStream(
pkcs11configBytes);
AuthProvider pkcs11Provider = new sun.security.pkcs11.SunPKCS11(
configStream);
pkcs11Provider.setCallbackHandler(new MyGuiCallbackHandler());
if (Security.getProvider(pkcs11Provider.getName()) != null) {
Security.removeProvider(pkcs11Provider.getName());
Security.insertProviderAt(pkcs11Provider, 2);
//Security.insertProviderAt(pkcs11Provider, 1);
System.setProperty("javax.net.ssl.keyStoreProvider",
pkcs11Provider.getName());
System.setProperty("javax.net.ssl.keyStoreType",
"PKCS11");
System.setProperty("javax.net.ssl.keyStore",
"NONE");
KeyManager[] KM = {KeyStore.getInstance("PKCS11") };
SSLContext sslcont = SSLContext.getInstance("SSL");
sslcont.init(null  /*KM*/ , tmS, rng);If i use KM everything works fine, but if I try to initialize the sslcontext using the default keyStoreProvider (just replacing KM with null, and without any other modification to the code), it uses SUN instead of PKCS11, even if I set the system properties javax.net.ssl.keyStore* (as you can see in my code)
Can anyone help me?
Thank's in advance and happy new year,
Patrizio

That's what I tried first, but it didn't work.
I followed instructions at
http://java.sun.com/j2se/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#CustomizingStores
Then I found something about dynamic provider allocation at
http://forum.java.sun.com/thread.jspa?forumID=2&threadID=5172412
so I tried to dynamically allocate SunPKCS11-bit4id as a provider.
Any suggestion?

Similar Messages

  • After update my iPad 2 with IOS 6.0.1 the botton mute and sound + doesn't work...any solution for this??? Thanks

    After update my iPad 2 with IOS 6.0.1 the botton mute and sound + doesn't work...any solution for this??? Thanks

    There are numerous reports of this issue happening on iPhones. It may be a glitch that will need a new update. Some find that a full shut-down and restart fixes that problem, but not always.

  • How can I avoid duplicates on contacts and how do I get contacts created on iPhone/ipad synchronized on my mac? so far it doesn't work correctly, just sometimes. same for icalendar

    how can I avoid duplicates on contacts and how do I get contacts created on iPhone/ipad synchronized on my mac? so far it doesn't work correctly, just sometimes. same for icalendar

    On your Mac, for duplicates, switching Contacts off then back on in System Preferences > iCloud may prevent duplicates.
    On the iPhone / iPad tap Settings > iCloud. Make sure Contacts and Calendars are swtiched on.
    Try restarting your Mac and your iOS devices when items won't sync as they should.
    To restart an iOS device:  Hold the On/Off Sleep/Wake button down until the red slider appears. Slide your finger across the slider to turn off iPhone. To turn iPhone back on, press and hold the On/Off Sleep/Wake button until the Apple logo appears.

  • Every time I use the internet the pages keep reloading every 10-20 seconds. worked with my internet provider for over a year thinking it was their fault, but it turns out it's my computer. Can anybody help? Thanks.

    Every time I'm using the internet, my pages reload every 10-20 seconds. Very aggravating. I worked with my internet provider for a year thinking it was their fault, but it turns out to be my computer, not the internet provider. Can anybody tell me why this is happening? Thank you.

    Hi Mary,
    Open Console in Applications>Utilities & see if there are any clues or repeating messages when this happens.

  • Hello, I've upgraded my Ipad2 to iOS7. I'm facing two major problems. First, I can't connect to the internet(which seems like a common problem). Second, the Autocad WS app doesn't work. It keeps asking for a username/passcode combination. please help guys

    Hello, I've upgraded my Ipad2 to iOS7. I'm facing two major problems. First, I can't connect to the internet(which seems like a common problem), no Wifi connectivity as well. Second, the Autocad WS app doesn't work. It keeps asking for a username/passcode combination. Please help me guys. I will be genuinely grateful.
    Cheers

    Does my problem has anything to do with SSL for mail settings? Cause when I tried re-adding it says something that I should try without SSL, and I did what you said and it gives me this "The IMAP server pop.mail.yahoo.com is not responding. Check your network connection and that you entered the correct information in the incoming mail server field". Ahh.. this is so annoying, Apple what are you doing to me?! Or is Yahoo doing this to me?!
    Thank you for your time. Sorry it doesn`t work.

  • Itunes not working as default media player for mp3's in firefox

    In Firefox (and I tried Safari with same results), clicking a link that is supposed to play an mp3, itunes is not completing the operation. itunes is set as the default media player. The mp3 file is actually loaded into user.AppData.Local.Temp, but it is not imported into itunes (nor played). I can move the file to the desktop and then move into itunes. Trying to move from .Temp directly into itunes doesn't work. What am I missing???

    Check out this thread for a possible resolution to your problem: http://discussions.apple.com/message.jspa?messageID=6825681

  • My blackberry messenger doesn't work its needs and update for q10

    my blackberry messenger says that it needs an update and it doesn't work for Q10 and when i search for update it shows that there is no update available than you

    Hey,
    Welcome to the BlackBerry® Support Community Forums.
    To better assist you can you please provide the full error message you receive when attempting to launch BlackBerry Messenger?
    Thank you.
    -HB
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • Site doesn't work - how to validate javascript for mac?

    hey folks,
    i spent ages for making my new site cross-browser-compatible, only to see safari not working at all.
    http://www.janfrisch.de/
    since the html validates as 4.01 transitional i presume the problem has to be discovered in the javascript section - but where?
    i can't get my hands on a mac, plus i heard the js debugging with safari isn't that easy.
    maybe it's just a really simple solution, like
    "<script type="text/javascript" src="scripts/janfrisch.js"></script>" in header doesn't work with safari or something? i don't have a clue. i'm not a js nor html expert as well.
    would be great if some of you have some helpful information.
    and sorry for my english. =)
    athlon   Windows 2000  

    Hello mablung & Welcome to Apple Discussions
    No problem with your english:-) Not sure if any of this helps, thought i would give it a try.
    http://validator.w3.org/
    I googled js debugging with safari, do any of these help?
    http://simon.incutio.com/archive/2003/12/13/ieGotcha
    http://dojo.jot.com/FAQ
    Any help? I hope so. Good luck
    Eme

  • SAP JVM default keystore file for Active MQ JMS SSL integration?

    Hi all,
    does the SAP JVM still have a default keystore file?
    I'm asking this question because I would like to integrate with Active MQ JMS SSL. The MQ-Libs are refering to the VMs default keystore in order to find the certificate for the SSL handshake.
    Kind regards,
    Heiko

    Same here, with almost the same things (JDK @ 1.5.0_16) but same WLS version, as well as Eclipse & WTP.
    Also have the Bea WLS Tools plugin 1.1.1
    Ideas right here...?

  • 3g doesn't work if the iphone asks for wi-fi connections

    If I try to connect to internet and the Iphone asks if I want connect to wi-fi and I don't want, the 3g doesn't work. Only after turn the iphone off/on the 3g works again.

    I didn't use the term Reboot since there is no such thing term wise.
    It is power off and on, then there is a Reset which is a system restart without powering the iPhone off and then a complete Restore.
    Basically a Reset accomplishes powering an iPhone off and on so not much point in doing so first.

  • SMS Service Provider for Unity Connection

    Hello,
    I am wondering if anyone has ever setup the SMS Message Notification feature within Unity Connectiona and if so, can you recommend the Service Provider that you used? I am having a hard time trying to find a provider for this feature.
    Thanks in advance for any help you can provide.
    Martin

    I had a customer do it with Sprint. They charged a per-message rate (more if they had to relay it to another carrier) and added it to the customer's business account. They were *very* guarded about the server details relating to the setup of it though. Yeesh.
    Please remember to rate helpful responses and identify helpful or correct answers.

  • Setting 'struct tm' tm_zone="GMT" doesn't work, takes default system timezone

    Dear Dev-Meisters,
    I'm trying to find out why setting  tm_zone="GMT" in a "struct tm" is not working on Mac OS X 10.6.x. and mktime()....
    However with gmtime() it works but apparently it's not recommended for Mac OS X...
    I need to read in a data file with large datasets which contains date / time along with data.
    Every date/time (can be about > 500000 lines) is converted to a time_t data structure to find out if there a gaps between dates.
    However setting the structure "struct tm" with tm_zone="GMT" doesn't set it to GMT.
    It always takes Mac OS X default time zone defined in the Sys Preferences.
    I made succesful tests with "NSDate timeIntervalSince1970" (when setting the NSTimezone to GMT): this gives the correct GMT time...
    Since > 500000 lines is a little bit overkill performance wise to always create an object I would prefer to use UNIX time stamp...
    /* Test for 24 Feb. 2005 at 17h20:10 / Should return: 1109265610 as UTC time */
    time_t currentTime;
    struct tm myTm;
    myTm.tm_year          = 2005-1900;  // need to subtract -1900
    myTm.tm_mon           = 2-1;        // need to subtract -1 (since month: 0-11) 
    myTm.tm_mday          = 24;
    myTm.tm_hour          = 17;
    myTm.tm_min           = 20;
    myTm.tm_sec           = 10;
    myTm.tm_zone          = "GMT";
    myTm.tm_isdst         = 0; // DayLight Saving Time flag = 0 = Off
    myTm.tm_gmtoff        = 0;
    currentTime = mktime(&myTm);
    Result on Mac OS X: 1109262010 !! Wrong result: -3600 seconds, should be 1109265610
    However using:
    currentTime = gmtime(&myTm);
    gives the right result: 1109265610
    Any suggestions is greatly appreciated

    Thanks for the answer, I read everything except the man page for mktime :-(
    Well I can't remember where I read that about "gmtime" but you are right:
    I will use gmtime instead of mktime and it works, it converts it to a GMT time.
    Thanks again for your precious help.
    Cheers,
    Gilles

  • Thunderbird doesn't work as default email client when sharing pdf attachments. Works fine if Mail is the default client

    With Tbird set as the default email client, whenever I try to email the pdf, a message pops up that the default client can't handle sending the attachment. It works all the time if the native Mac Mail software is the default client..
    This forces me to save the pdf file, go to Tbird to send a message and then have to find the file in the folder structure to add as an attachment.

    My PDF software is Adobe Acrobat. So what is wrong with your Thunderbird software I must ask!

  • Mail & Contacts: "Italic" doesn't work on default message font

    On Mail Preferences/Fonts and colours I set the default message font as a Calibri Italic 15.
    Now, the problem is that opening a new message I get Calibri 15 BUT NOT Italic. I have to make it manually...
    Does anyone know why this happens and the way to solve this issue?
    Thanks

    There is a way around this (thanks to apple for responding to my bug submission) but it's slow. Test to see if the glyphCode created is greater than zero or not:
    final FontRenderContext fontRenderContext = new FontRenderContext(null, false, false);
    char[] array = new char[1];
    array[0] = (char) intvalueofchar;
    GlyphVector glyphVector = glyphFont.createGlyphVector(fontRenderContext, array);
    int glyphCode = glyphVector.getGlyphCode(0);
    boolean validchar = (glyphCode > 0);I only need to do this on the mac; on windows it does the right thing without this. If anyone has any suggestions for speeding it up (I already have it running in a thread), that'd be great - but thought I'd post it here for anyone else who might run into the same problem some day.

  • Native mapping with JPA doesn't work by default - not marked cascade persi

    I started to use our old TopLink native mapping but via JPA instead of EclpseLink native API.
    But at first execution it's already complaining of my mappings. When using the native mappings shouldn't EclipseLink interpret it to keep old behavior?
    What are the other expected changes of behavior so that I can fix them proactively?
    What is the workaround for this specific problem?
    The error is:
    java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST: Id: 0
    DateTime: Mon Jun 08 02:00:00 EDT 2009
    Entry Type: 10009
    Entry Type In/Out: 10014
    calendarDate: Mon Jun 08 00:00:00 EDT 2009
    businessDate: Mon Jun 08 00:00:00 EDT 2009
    origin: timecard
    Inserted: true
    Changed: false
    Deleted: false
    Mon Jun 08 02:00:00 EDT 2009.
         at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.discoverAndPersistUnregisteredNewObjects(UnitOfWorkImpl.java:4016)
         at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.discoverUnregisteredNewObjects(RepeatableWriteUnitOfWork.java:182)
    persistence.xml is:
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
         <persistence-unit name="AllInOne" transaction-type="JTA" >
         <description>This represent all CITYADM schema mappings. It does include pmsi.</description>
              <exclude-unlisted-classes>false</exclude-unlisted-classes>
              <properties>
                   <property name="eclipselink.session-name" value="AllInOne"/>
                   <property name="eclipselink.sessions-xml" value="sessions.xml"/>
              </properties>
         </persistence-unit>
         <persistence-unit name="DataServices" transaction-type="JTA">
         <description>This represent all REPORTADM schema mappings</description>
              <exclude-unlisted-classes>false</exclude-unlisted-classes>
              <properties>
                   <property name="eclipselink.session-name" value="DataServices"/>
                   <property name="eclipselink.sessions-xml" value="sessionsDataServices.xml"/>
              </properties>
         </persistence-unit>
    </persistence>

    Hello Sebastien,
    You are using em.persist instead of uow.regsiterObject, which has different behaviour as mandated by the JPA specification. EclipseLink/TopLink automatically registered referenced objects through registerObject, but the JPA specification states that persist will only cascade if the mapping is marked cascade persist - otherwise it is required to throw the exception you see.
    If you wish to use the JPA with a project defined through native api, you will need to modify your mappings to match how you want to use the API. In this case, to get the same effect as you would from registerObject, you will need to mark your mappings as cascade persist. Depending on how you merge your entities (shallow, deep etc) you might also need to evaluate how you plan to use the JPA merge method and mark mappings as cascade merge appropriately.
    See setCascadeMerge on ForeignReferenceMapping.
    Best Regards,
    Chris

Maybe you are looking for

  • No bootable device -- insert boot disc and press any key

    Hello, I'm trying to install Windows 7 on BootCamp. I have iMac 2010. My CD-ROM is broken, i can't put CD into it. So, i use external CD-ROM. I burned DVD with windows 7 ISO file, started BootCamp Assistant, My computer restarted and then i have blac

  • Restore from Backup DVD

    wondering, does FACES not get back up'd. After I imported the iphoto library off of the dvd, it looks like faces didn't save?

  • Processing exception during a "Render" operation issue

    Hi all, I got below error message when i try to view pdf file in portal. It is working fine to view the adobe form using fp_test_00 program. Processing exception during a "Render" operation. Request start time: Tue Jul 21 08:03:17 BST 2009 com.adobe.

  • Adobe 6: Setting PrinterJobControl does not work

    Hello, I'm using Visual Basic 5 for creating PDF-Files to archive some documents. I want Adobe to put the files automatically to a specified folder. In the Adobe-API I read that I have to set an entry in the PrinterJobControl-RegKey. I tried this but

  • Mainstage folder and spotlight.

    Hi everyone. I can't find channel strips settings (for example 01 Acoustic Pianos) in the spotlight search. I wanted to know the file three to find this channel strips settings. I have repair disk permission feature and make a reindexation. Thanks fo