Re-using SSLSession with different SSLSockets

I saw this question asked multiple times in the past but I have never seen the answer. Does anybody how to re-use SSLSession when creating multiple SSLSockets?
Thanks, Kris

Based on my testing SUN's SSL implementation creates and reuses SSL session automatically.
You need to use one socket factory to create all your sockets.
You execute handshake only on the first socket. Handshaking creates the session.
The other sockets will not need hadshaking assuming you will use the same socket factory.
All the sockets created in this manner will reuse the same session.
You can close all the sockets and the SSL Session is still kept alive.
To prove my point I have modified sample Client that is bundled with JSSE package.
Running Client produces the results:
D:\Download\Test1>java SSLSocketClient localhost 7000
Session for socket1 (1549180): 7224672
Session for socket2 (8365662): 7224672
As you can see from the results there are two different sockets reusing the
same session. The first socket is closed before the second socket is opened.
The sample is below, the changes are mostly at the end of the file
// Begin of the sample
import java.net.*;
import java.io.*;
import javax.net.ssl.*;
import javax.net.*;
* This example demostrates how to use a SSLSocket as client to
* send a HTTP request and get response from an HTTPS server.
* It assumes that the client is not behind a firewall
public class SSLSocketClient {
public static void main(String[] args) throws Exception {
     try {
/*     SSLSocket socket =
          (SSLSocket)factory.createSocket("www.verisign.com", 443);
     int port = 7030;
     String host = "localhost";
     if (args.length > 1) {
          host = args[0];
          try {
               port = Integer.parseInt(args[1]);
          catch (Throwable th) {}
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.ssl.trustStore", "testkeys");
     SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket sslsocket1= (SSLSocket)factory.createSocket(host, port);
     sslsocket1.startHandshake();
     System.out.println("Session for socket1 (" + sslsocket1.hashCode() + "): " + sslsocket1.getSession().hashCode());
     // first socket being closed
sslsocket1.close();
SSLSocket sslsocket2= (SSLSocket)factory.createSocket(host, port);
     System.out.println("Session for socket2 (" + sslsocket2.hashCode() + "): " + sslsocket2.getSession().hashCode());
sslsocket2.close();
     } catch (Exception e) {
     e.printStackTrace();
//End of the Sample

Similar Messages

  • Can two peeps use iChat with different accounts on the same computer?

    What do I do to REMOVE an old AIM account and replace it with a new account in IChat?
    Can two peeps use iChat with different accounts in the same computer?
    (Actually, two people share a laptop, but one of us cannot use her AIM account cuz mine is in iChat already... And, when traveling, I have the computer - and I would like to use iChat on the computer...)

    In iChat 4 you can have more than one AIM Valid name logged in at once.
    AIM valid = AIM, @mac.com or a MobileMe name.
    What you are then stuck with is that iChat is linked to one Buddy Picture and The one Mac User Account's Address Book which may or may not have Full Names, emails details, or a Nickname in iChat 4 linked to the Screen Names.
    Whilst it does let you both log in whilst using one Mac User Account there are drawbacks about who uses the keyboard and reading meesages from the other persons Buddies.
    8:50 PM Sunday; November 30, 2008

  • Using scripts with different versions of AppleScript

    Hi,
    I have a script that works perfectly in my Apple Script Editor v2.4.3 and Language AppleScript 2.2.1   I've given that script to a friend of mine with AppleScript Editor 2.7 and Apple Script Language 2.4
    The script does not work properly in their AppleScript Editor, does anyone know why this might be and/or how to remedy it?  Is there a way for them to download Language 2.2.1 to use or is there a way to figure out how I need to update my code to work for the 2.4 language.
    Thanks

    Hello
    Whilst scripts using certain features of the latest version of AppleScript language won't even complile on previous versions, scripts written for previous versions should usually work in later versions with some exceptions.
    cf.
    https://developer.apple.com/library/mac/releasenotes/AppleScript/RN-AppleScript/
    https://developer.apple.com/library/mac/releasenotes/AppleScript/RN-AppleScript/ RN-AppleScript.pdf
    - Notable change introduced in 10.8 is new requirement on referencing file system object.
    E.g.,
    open "/path/to/file"
    may work under 10.7 but not under 10.8 or later. Instead you need to use:
    open "/path/to/file" as POSIX file
    etc.
    - Notable change introduced in 10.9 is new requirement on using Accessibility and GUI scripting.
    cf.
    OS X: Using AppleScript with Accessibility and Security features in Mavericks
    http://support.apple.com/kb/HT5914
    Good luck,
    H

  • Can one ODI procedure be used twice with different option in one package?

    I have a procedure with three check box type options. This procedure is used twice in a package. I tried to set options differently in the package, but once I set up the options for the second call, the first one will be updated to the same as the second one automatically. Is the option supposed be used as parameter? If it is true, why I cannot call procedure twice by using two different parameter settings?
    Thanks

    Create two scenarios of the same procedure. While generating scenarios change the options as necessary. Then in the package call the scenarios instead of the procedure. That should work.

  • How do you use itunes with different iphone without syncing information

    I am sharing itunes with my kids. I am trying to findout how do we use the same itunes wothout sharing contacts. My kids keep deleting my contacts? Is there a setting that will stop this from happening?

    How to use multiple iPods, iPads, or iPhones with one computer

  • How to use EVS with different data in each row, in a Java Web Dynpro table?

    Hi all,
    I am using EVS in a column of java web dynpro table.
    Let's say the name, and context attribute, of this column is column1.
    It's filled dynamically using an RFC, that uses as input parameter the value of another column, and related context attribute, from the same table (Let's call it column2).  Obviously, from the same row. So, in other words: the values of the EVS in column1 of row1, are dependent of the value of column2 of row1. And the values of the EVS in column1 of row2, are dependent of the value of column2 of row2. And so on... Hope i could explain myself ok.
    The code I'm using works great for filling the EVS dynamically:
    IWDAttributeInfo attrInfo = wdContext.nodeDetail().getNodeInfo().getAttribute(nodeElement.COLUMN1);
    ISimpleTypeModifiable siType = attrInfo.getModifiableSimpleType();
    IModifiableSimpleValueSet<String> value = siType.getSVServices().getModifiableSimpleValueSet();
    value.clear();
    if(this.initRFC_Input(nodeElement.getColumn2())){
         for (int i = 0; i < wdContext.nodeRFCresult().size(); i++){
              value.put(wdContext.nodeRFCresult().getRFCresultElementAt(i).getLgort()
                 , wdContext.nodeRFCresult().getRFCresultElementAt(i).getLgobe());
    In this code, nodeElement is the context row of the table that is passed dynamically to the method when the value of colum2 is changed.
    HOWEVER, the problem I'm having is that after executing this code, EACH NEW ROW that is added to the table has by default the same values as the first row, in the column1 EVS. And, for example, if I refresh the values of the column1 EVS in row 2, all EVS values in the other rows are also refreshed with the same values as the ones of EVS in row 2.
    How can I make sure each row EVS has its own set of independent values, so they don't mess with each other?
    Hope you guys can help me. And please, let me know if I didn't explain myself correctly!
    Thanks!

    I just did as you said (I think), but it's still having the same behaviour as before (same data for all EVS in the table).
    Here´s what I did:
    I
    In node "Detail" (cardinality 0...n, singleton set to true), which is binded to the table, I created a child node named "Column1Values" wth cardinality 1...1 and singleton set to false.
    "Column1Values" node has an attribute called "column1", of type String.
    I did the binding between attribute "column1" and the column1 inputfield celleditor in the table.
    I created an event called Column2Changed and binded it to the column2 celleditor of the table. I added a parameter called nodeElement of type IPrivateCompView.IDetailElement to this event, and mapped it to the column2 editor in the table so that I can dynamically get the nodeElement that is being affected.
    I added the following code to the onActionColumn2Changed(wdEvent, nodeElement) method that gets created in the view:
    IWDAttributeInfo attrInfo = nodeElement.nodeColumn1Values().getNodeInfo().getAttribute("column1");
    ISimpleTypeModifiable siType = attrInfo.getModifiableSimpleType();
    IModifiableSimpleValueSet<String> value = siType.getSVServices().getModifiableSimpleValueSet();
    if(this.initRFC_Input(nodeElement.getColumn2())){
         for(int i =0; i < wdContext.nodeRFCresults().size(); i++){
              value.put(wdContext.nodeRFCresults().getRFCresultsElementAt(i).getId(),
                                  wdContext.nodeRFCresults().getRFCresultsElementAt(i).getDesc());
    And with this, I still get the original problem... When the EVS of one row is updated, ALL other EVS of the table get also updated with the same values.
    What am I missing? Sorry Govardan, I bet I'm not seeing something really obvious... hopefully you can point me in the right direction.
    Thanks!

  • Short dump using CS_BOM_EXPL_MAT_V2 with different user ids

    Hi
    We are getting a short dump in our program when using FM'CS_BOM_EXPL_MAT_V2' and this is happening only for super user roles but not with regular user ids in production. We are not able to identify the solution yet, and it needs to be resolved as quickly as possible. Anyhelp, really appreciated.
    Thanks
    Anil
    Here is our code:
      CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
        EXPORTING
          aumgb                 = 'X'
          capid                 = 'PP01'
          datuv                 = p_valfrm
          ehndl                 = '1'
          emeng                 = 1
          mbwls                 = ' '
          mehrs                 = 'X'
          mmory                 = '1'
          mtnrv                 = p_matnr
          stlal                 = p_stlal
          stlan                 = p_stlan
          werks                 = p_werks
        TABLES
          stb                   = i_stb
          matcat                = i_matcat
        EXCEPTIONS
          alt_not_found         = 1
          call_invalid          = 2
          material_not_found    = 3
          missing_authorization = 4
          no_bom_found          = 5
          no_plant_data         = 6
          no_suitable_bom_found = 7
          conversion_error      = 8
          OTHERS                = 9.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

    Hi senthil,
    1. I suppose u want to explode the BOM.
    2. CS_BOM_EXPLOSION
       use the above FM
       in the below mentioned fashion.
    3.
      CALL FUNCTION 'CS_BOM_EXPLOSION'
       EXPORTING
       capid                       = 'PP01'
       emeng                       = bmeng
       datuv                       = sy-datum
       mtnrv                       = matnr
       stlan                       = '1'
         werks                       =  werks
         mehrs = 'X'
    IMPORTING
      TOPEQUI                     =
      TOPMAT                      =
      TOPTPL                      =
      DSTST                       =
        TABLES
          stbd                        = stbd
          stbe                        = stbe
          stbk                        = stbk
          stbm                        = stbm
          stbp                        = stbp
          stbt                        = stbt
    EXCEPTIONS
       alt_not_found               = 1
       call_invalid                = 2
       missing_authorization       = 3
       no_bom_found                = 4
       no_plant_data               = 5
       no_suitable_bom_found       = 6
       object_not_found            = 7
       conversion_error            = 8
       OTHERS                      = 9
    regards,
    amit m.

  • BT Hub 2.0 - Can I use this with different ISP?

    I use TalkTalk as my ISP and have recently had a BT engineer call-out due to my very low BB speed.  As my master socket is in the lounge dowstairs and I want the PC upstairs the BT man suggested I switch to wireless.
    Bought the BT Hub 2.0 on recommendation, but have now read that it can only be used when BT is the ISP.
    Is this correct and is there anyway around it?

    The BT Homehub can only be used with BT Broadband, it is possible to "flash the firmware" to unlock it to other ISPs, but this is not really a simple task.
    Why not contact talk talk and tell them you are thinking of leaving, I am sure they will do you a deal and send you a new wireless router, or you could always get one from that well known on line auction website.
    (If I have helped you in any way to say "Thank You" please click on the star next to the message. Thank You)
    If I have solved your Issue please click the "Mark as accepted solution" button.

  • Using DisplayPixels with different image formats

    According to the comments in PIGeneral.h (in the PSPixelMap declaration), the DisplayPixels function can handle only grayscale, RGB, CMYK, and Lab images, plus Duotone and Indexed if it matches the document's format (presumably because the function wants to use the palette from the document). I have a multichannel image that I'd like to draw.
    The question is, is there any way to get Photoshop to convert this to a usable format for me? Since I don't know the channel characteristics, I don't think I can do it myself. Alternatively, is there a way to deduce the conversion from the ReadChannelDesc structures in the FilterRecord? Does anybody have code to do this?
    Thanks,
    Aaron

    Hi Mathias,
    this is not possible issuing just one request. You would need to repeat the request changing the format.
    Joao

  • Possibility to use 3G with different providers

    Hi guys!
    Please answer on a simple question:
    Is it possible to use SIM cards from any providers not only AT&T in iPad which purchased in USA? I'm going to buy device in US and use it in Russia (3G here available).
    Thank you in advance!

    Roman ~ Welcome to the discussions.
    Roman Moiseev wrote:
    Is it possible to use SIM cards from any providers not only AT&T in iPad which purchased in USA?
    Yes, as long as it is a micro-SIM card. It's also possible to cut a SIM card down to micro-SIM size — see THIS article. And see these Apple docs:
    _How to identify a micro-SIM_
    _iPad Wi-Fi + 3G: Connect to iTunes when activating a new micro-SIM_
    Roman Moiseev wrote:
    Thank you in advance!
    You're welcome!

  • Use Iweb with different host?

    I am considering purchasing Ilife 2006, because of the iweb feature. Could anyone tell me if it is at all possible to create an iweb site and upload it to a different host and not i.mac?
    thanks
    Nikki

    It is no problem!
    I have put two sites up on non .mac accounts. You simply publish to folder and then ftp the files to your web hosting account. Note: When you publish to a folder it will ask you the url of your website to adjust the RSS and Podcast subscribe links.
    HOT TIP: It appears that if you try to manage two websites from iWeb, it will create a problem since each time it publishes to a folder, it will adjust the subscribe links which would break them for the site you aren't publishing.
    So if you want to work on multiple sites ... I have discovered the secret work-around! When you want to create another site ... create a new user account and launch iWeb from there. This will allow you to create and update a new website without any problems.

  • Using remote with more then one computer.

    Can i use remote with different computers? It works fine on mine but if i try to use it with another computer in the house it doesn't show up in itunes.

    If you want to connect and use an iPod (other than a shuffle) on more than one computer you need to change the update preference in the iPod Summary tab to "Manually manage music and videos" and click Apply.
    Using iPod with Multiple computers
    Managing content manually on iPod
    Note: When changing from automatic to manual, check the "manually manage music and videos" box in Summary then press the Apply button. "Don't" uncheck Sync Music in the Music tab, it will be unchecked by default when you choose the manual setting, if you uncheck it without setting the iPod to manual first you'll erase all the songs from your iPod
    Something else to be aware of when using an iPod in manual mode is that the "Do Not Disconnect" message will remain on the display until you physically eject the device. In that case use Safely Remove Hardware icon in the Windows system tray on your desktop or check this link: Safely Disconnect IPod

  • Can i use 2 ipad's on the same itunes account with different apple accounts?

    Both me and partner have an ipad 4. Though we only have one computer, can we use the same itunes but with different apple acount without any issues? We use some of the same apps, but my partner plays fx Baldus Gate and is worries that save files will be corrupted.

    Each iPad should be linked to its owner's personal, private and nonshared AppleID. In the Mac, each one should have a different login account so each has their own iTunes Library containing your iPad's details. When you use iTunes on the Mac, since each logs in with a different login and corresponding Home directory, iTunes picks up the correct AppleID.

  • HT204053 i RECENTLY PURCHASED ANOTHER IPHONE.  MY INTERNET IS NOT WORKING.  I JUST CREATED AN APPLE ID.  WHAT'S NEXT?  I NOW HAVE TWO DIFFERENT ACCOUNTS WITH DIFFERENT USER NAMES.  HOW CAN I USE ONLY ONE ACCOUNT FOR ITUNES, ICLOUD APPLE ID ETC???

    I RECENTLY PURCHASED ANOTHER IPHONE.  MY INTERNET IS NOT WORKING.  I JUST CREATED AN APPLE ID.  WHAT'S NEXT?  I NOW HAVE TWO DIFFERENT ACCOUNTS WITH DIFFERENT USER NAMES.  HOW CAN I USE ONLY ONE ACCOUNT FOR ITUNES, ICLOUD APPLE ID ETC???

    Welcome to the Apple community.
    iTunes and iCloud and different accounts, you will need to delete both accounts from your device before adding the new details in their place.
    For iCloud go to settings > iCloud, scroll down and hit the delete button. You can then sign back in using your correct details. For iTunes go to settings >store, tap your account ID and then sign out, you can then sign back in using your correct Apple ID.

  • How do I use iTunes on one computer to manage two iPads with different contents?

    I just bought an iPad Air 2 and want to use it with iTunes on my MacBook Pro.  No problem so far!  However, I want to continue to use my "old" iPad 2 for my wife and want to keep managing it as I always have using iTunes on my MacBook Pro.  The thing is that I want to make it possible for the two iPads to have quite different content to allow for the different needs and tastes of my wife and me.  How should I go about this?
    Thanks for any help.

    Hi Brett,
    Thanks very much for the information.
    I took a look at it but it seems to be aimed solely at "media" on an iPad, i.e. movies, music, TV shows etc.  This is fine, but I also want to be able to deal with all the apps on each iPad too, so that when I connect each iPad to my MacBook through iTunes, the synching process works just like it always has for my first iPad (an IPad 2).  I don't mean that I want all the apps on both iPads to be the same (my wife doesn't need all the apps that are on the iPad 2 at present), but I do want to be able to add/remove/update media and apps on each iPad, and update the iOS on each iPad. 
    Basically, I guess, I want a situation whereby when I plug in either of the iPads, iTunes recognizes each as a separate device and has a totally separate "library" (backup?) of music, movies, TV shows, etc. and — most importantly — apps.  Is that possible?
    Regards,
    Chris

Maybe you are looking for

  • Hard drives damaged after installing Snow Leopard :(

    After installing Snow Leopard all software seemed to work fine. Then I found out that e-sata doesn't seem to work well with Snow. I've tried two different e-sata cards, including CalDigit's FASTA-2e, which CalDigit claims works fine with 10.6. My ext

  • JTable with JCheckbox problems

    Ok so I have a couple of questions. I have a JTable with a column represented as a checkbox. 1. If I put the checkbox column as the first in the table, the rest of the cells are blank/null. Any idea what the reason is? 2. What is the best workaround

  • Can't print using a Canon MF4370dn/ OS 10.6.8

    Am running a quad core with 10.6.8, with the printer USB hardwired, and have done the following: Repaced the USB cable; Deleted and re-installed UFR2 v 2.2, including the .plist; run repair disk permissions; deleted and re installed the printer The p

  • GPS in Miix 10''

    I have the 3G/GPS model of Lenovo Miix running on Windows 8.1 but it seems the Windows location utility does not work with the gps hardware (HUAWEI GNSS Sensor) at all and determines the location just based on the wifi/cellular basis. Is that so (I f

  • Lion Finder Behaving Badly

    My wife has a 27' iMac w. 10.7.2, 2.8 GHz Core i7, 8 GB Ram. She runs the iMac as Admin. Finder preferences don't stick She does not want to see "All My Files" or "Air Drop" in the Sidebar. She changes the preferences, but those items keep reappearin