ORACLE EXPORT FAILING ON A WINDOWS SERVER

Hi All
I have a windows server 2003 sp2. Recently i reinstalled oracle software on it. Since then my exports have started failing with the following message
Message 206 not found; No message file for product=RDBMS, facility=EXP: Release 10.2.0.4.0
It says it has something to do with oracle home but my oracle home is set correctly
Has anyone encountered something like this. Your comments highly appreciated as always !!
thanks!!

check your environment variables, including ORACLE_HOME and PATH.

Similar Messages

  • Error on clone database, oracle 10g release 2 for windows server 2008

    Hi,
    OS: Windows Server 2008 X64
    Oracle: oracle 10g release r2 for windows server 2008
    An error occurred when creating a database, stop at last step, Screenshot:
    [http://temp.wsria.com/oracle_create_db.png|http://temp.wsria.com/oracle_create_db.png]
    the trace log content:
    [main] [9:56:35:982] [CommandLineArguments.process:563] CommandLineArguments->process: number of arguments = 32
    [main] [9:56:35:982] [CommandLineArguments.process:738] CommandLineArguments->process: Create Database argument is specified
    [main] [9:56:35:982] [CommandLineArguments.process:910] CommandLineArguments->process: template Name argument is specified
    [main] [9:56:35:982] [CommandLineArguments.process:960] CommandLineArguments->process: db name argument is specified
    [main] [9:56:35:982] [CommandLineArguments.process:3074] CommandLineArguments->process: in Operation Type is Creation/GenerateScripts Mode condition
    [main] [9:56:35:997] [CommandLineArguments.process:3298] CommandLineArguments->process: Successfully process command line arguments
    [main] [9:56:36:668] [Host.checkOPS:2055] Inside checkOPS
    [main] [9:56:36:668] [Host.checkOPS:2067] Trying to check cluster existence
    [main] [9:56:36:715] [Library.getInstance:97] Created instance of Library.
    [main] [9:56:36:715] [Library.load:197] Loading orauts.dll...
    [main] [9:56:36:715] [Library.load:203] oracleHome D:\oracle\product\10.2.0\db_1
    [main] [9:56:36:715] [sPlatform.isHybrid:63] osName=Windows Vista osArch=amd64 rc=false
    [main] [9:56:36:715] [Library.load:223] Loading library D:\oracle\product\10.2.0\db_1\bin\orauts.dll
    [main] [9:56:36:715] [Library.load:247] Loaded library D:\oracle\product\10.2.0\db_1\bin\orauts.dll from path=
    D:\oracle\product\10.2.0\db_1\bin
    [main] [9:56:36:715] [Library.load:197] Loading MSVCRT.dll...
    [main] [9:56:36:715] [Library.load:203] oracleHome D:\oracle\product\10.2.0\db_1
    [main] [9:56:36:715] [sPlatform.isHybrid:63] osName=Windows Vista osArch=amd64 rc=false
    [main] [9:56:36:715] [Library.load:223] Loading library D:\oracle\product\10.2.0\db_1\bin\MSVCRT.dll
    [main] [9:56:36:731] [Library.load:247] Loaded library D:\oracle\product\10.2.0\db_1\bin\MSVCRT.dll from path=
    D:\oracle\product\10.2.0\db_1\bin
    [main] [9:56:36:731] [Library.load:197] Loading orawsec10.dll...
    [main] [9:56:36:731] [Library.load:203] oracleHome D:\oracle\product\10.2.0\db_1
    [main] [9:56:36:731] [sPlatform.isHybrid:63] osName=Windows Vista osArch=amd64 rc=false
    [main] [9:56:36:731] [Library.load:223] Loading library D:\oracle\product\10.2.0\db_1\bin\orawsec10.dll
    [main] [9:56:36:731] [Library.load:247] Loaded library D:\oracle\product\10.2.0\db_1\bin\orawsec10.dll from path=
    D:\oracle\product\10.2.0\db_1\bin
    [main] [9:56:36:731] [Library.load:197] Loading orasrvm10.dll...
    [main] [9:56:36:731] [Library.load:203] oracleHome D:\oracle\product\10.2.0\db_1
    [main] [9:56:36:731] [sPlatform.isHybrid:63] osName=Windows Vista osArch=amd64 rc=false
    [main] [9:56:36:731] [Library.load:223] Loading library D:\oracle\product\10.2.0\db_1\bin\orasrvm10.dll
    [main] [9:56:36:731] [Library.load:247] Loaded library D:\oracle\product\10.2.0\db_1\bin\orasrvm10.dll from path=
    D:\oracle\product\10.2.0\db_1\bin
    [main] [9:56:36:731] [Version.isPre10i:189] isPre10i.java: Returning FALSE
    [main] [9:56:36:731] [WindowsSystem.regKeyExists:1006] WindowsSystem.regKeyExists: mainkey= HKEY_LOCAL_MACHINE subkey = Software\Oracle\Ocr
    [main] [9:56:36:746] [WindowsSystem.getCSSConfigType:1163] configType=null
    [main] [9:56:36:746] [Host.checkOPS:2073] cluster existence:false
    [main] [9:56:36:746] [Host.checkOPS:2111] Cluster installed=false
    [main] [9:56:36:902] [InitParamHandler.endElement:506] CustomSGA flag: false
    [main] [9:56:36:902] [InitParamHandler.endElement:507] Database Type: MULTIPURPOSE
    [main] [9:56:36:918] [InitParamHandler.endElement:508] Mem Percentage: 40
    [main] [9:56:36:918] [InitParamHandler.endElement:526] distributing Memory: 13737443328
    [main] [9:56:36:918] [MemoryCalculator.calculateMemory:122] Setting SGA to MAX_SGA 1610612736
    [main] [9:56:36:918] [StorageAttributes.setAttribute:232] IN threadID:1 group#=1
    [main] [9:56:36:918] [StorageAttributes.setAttribute:232] IN threadID:1 group#=2
    [main] [9:56:36:918] [StorageAttributes.setAttribute:241] Current threadID=1
    [main] [9:56:36:918] [StorageAttributes.setAttribute:248] Current threadID=1 ==> redoGroups[0]=1
    [main] [9:56:36:918] [StorageAttributes.setAttribute:258] vRedoGroups:[1]
    [main] [9:56:36:918] [StorageAttributes.setAttribute:288] setAttribute: bExists=false
    [main] [9:56:36:918] [StorageAttributes.setAttribute:232] IN threadID:1 group#=3
    [main] [9:56:36:918] [StorageAttributes.setAttribute:241] Current threadID=1
    [main] [9:56:36:918] [StorageAttributes.setAttribute:248] Current threadID=1 ==> redoGroups[0]=1
    [main] [9:56:36:918] [StorageAttributes.setAttribute:248] Current threadID=1 ==> redoGroups[1]=2
    [main] [9:56:36:918] [StorageAttributes.setAttribute:258] vRedoGroups:[1, 2]
    [main] [9:56:36:933] [StorageAttributes.setAttribute:288] setAttribute: bExists=false
    [main] [9:56:36:933] [TemplateManager.parseCloneTemplate:1477] See for any transportable datafiles in TemplateManager.....
    [main] [9:56:36:933] [TemplateManager.isInstallTemplate:2178] Selected Template by user:=General Purpose
    [main] [9:56:36:933] [TemplateManager.isInstallTemplate:2185] The Message Id to be searched:=GENERAL_PURPOSE
    [main] [9:56:36:933] [TemplateManager.parseCloneTemplate:1489] create new clone data file for tp file.......
    [main] [9:56:36:933] [Host.setupOIDCommandlineParameters:7184] setupOIDCommandlineParameters:
    [main] [9:56:36:933] [Host.setupOIDCommandlineParameters:7185] m_regWithdirService: false
    [main] [9:56:36:933] [Host.setupOIDCommandlineParameters:7186] m_unregWithdirService: false
    [main] [9:56:36:933] [Host.setupOIDCommandlineParameters:7187] m_updateDirService: false
    [main] [9:56:36:933] [Verifier.processRawConfigFile:3523] StorageType == 0
    [main] [9:56:36:933] [Verifier.setOradataDest:4349] setOradataDest:dfDest=D:\oracle\product\10.2.0\oradata
    [main] [9:56:36:933] [TemplateManager.updateDatafileDestination:1957] updateDatafiles:datafileDir=D:\oracle\product\10.2.0\oradata
    [main] [9:56:36:933] [TemplateManager.updateDatafileDestination:2103] From template, RedoLogGrName=1
    [main] [9:56:36:965] [TemplateManager.updateDatafileDestination:2118] new file name redo01.log
    [main] [9:56:36:965] [TemplateManager.updateDatafileDestination:2103] From template, RedoLogGrName=2
    [main] [9:56:36:965] [TemplateManager.updateDatafileDestination:2118] new file name redo02.log
    [main] [9:56:36:965] [TemplateManager.updateDatafileDestination:2103] From template, RedoLogGrName=3
    [main] [9:56:36:965] [TemplateManager.updateDatafileDestination:2118] new file name redo03.log
    [main] [9:56:36:965] [ProgressOnlyHost.performOperation:162] processRawConfigFile=false
    [main] [9:56:36:965] [Verifier.validateTemplate:1629] StorageType == 0
    [main] [9:56:36:965] [ProgressOnlyHost.performOperation:178] validateTemplate=true
    [main] [9:56:36:965] [OracleHome.isRacEnabled:149] bRacOn = false
    [main] [9:56:36:980] [Verifier.validateTemplate:1629] StorageType == 0
    [main] [9:56:36:980] [Verifier.calculateCloneDatafilePathsAndSizes:2951] canonicalPath=D:\oracle\product\10.2.0\
    [main] [9:56:36:980] [Verifier.calculateCloneDatafilePathsAndSizes:2951] canonicalPath=D:\oracle\product\10.2.0\
    [main] [9:56:36:980] [Verifier.calculateCloneDatafilePathsAndSizes:2951] canonicalPath=D:\oracle\product\10.2.0\
    [main] [9:56:36:980] [Verifier.calculateCloneDatafilePathsAndSizes:2951] canonicalPath=D:\oracle\product\10.2.0\
    [main] [9:56:36:980] [Verifier.calculateCloneDatafilePathsAndSizes:2951] canonicalPath=D:\oracle\product\10.2.0\
    [main] [9:56:36:980] [Verifier.calculateRedoLogGroupFileSizes:3083] canonicalPath=D:\oracle\product\10.2.0\
    [main] [9:56:36:980] [Verifier.calculateRedoLogGroupFileSizes:3083] canonicalPath=D:\oracle\product\10.2.0\
    [main] [9:56:36:980] [Verifier.calculateRedoLogGroupFileSizes:3083] canonicalPath=D:\oracle\product\10.2.0\
    [main] [9:56:36:980] [Verifier.getControlfFileSizes:3001] No. of Control files:=3
    [main] [9:56:37:105] [Host.executeSteps:4044] Executing steps....
    [main] [9:56:37:105] [Host.setUpForOperation:2920] setUpForOperation: Mode = 128
    [main] [9:56:37:121] [Host.executeSteps:4186] setupForOperation returned: true
    [main] [9:56:37:121] [Host.createStepSQLInterface:5948] sid =ora10g
    [main] [9:56:37:136] [SQLEngine.initialize:242] Execing SQLPLUS/SVRMGR process...
    [main] [9:56:37:136] [SQLEngine.initialize:270] m_bReaderStarted: false
    [main] [9:56:37:136] [SQLEngine.initialize:274] Starting Reader Thread...
    [Thread-4] [9:56:37:355] [StepContext$ModeRunner.run:2478] ---- Progress Needed:=true
    [Thread-4] [9:56:37:464] [BasicStep.execute:202] Executing Step : CLONE_DB_CREATION_RMAN_RESTORE
    [Thread-4] [9:56:37:464] [StepErrorHandler.setFatalErrors:322] setting Fatal Error: ORA-01092
    [Thread-4] [9:56:37:464] [StepErrorHandler.setFatalErrors:322] setting Fatal Error: ORA-01034
    [Thread-4] [9:56:37:464] [StepErrorHandler.setFatalErrors:322] setting Fatal Error: ORA-03114
    [Thread-4] [9:56:37:464] [StepErrorHandler.setFatalErrors:322] setting Fatal Error: ORA-12560
    [Thread-4] [9:56:37:464] [StepErrorHandler.setIgnorableErrors:250] setting Ignorable Error: ORA-01109
    [Thread-4] [9:56:37:464] [BasicStep.configureSettings:304] messageHandler being set=null
    [Thread-4] [9:56:37:464] [BasicStep.execute:202] Executing Step : INSTANCE_CREATION
    [Thread-4] [9:56:37:464] [BasicStep.configureSettings:304] messageHandler being set=null
    [Thread-4] [9:56:37:479] [InitParamAttributes.sortParams:3532] m_sortOn:-1 sortOn:4
    [Thread-4] [9:56:37:620] [OracleHome.isRacEnabled:149] bRacOn = false
    [Thread-4] [9:56:37:667] [Host.noEntryinOratab:5115] Check made for oratab arg passed............
    [Thread-4] [9:56:37:667] [Oradim.getAddEntryCommand:353] AddEntry=[D:\oracle\product\10.2.0\db_1\bin\oradim.exe, -new, -sid, ORA10G, -startmode, manual, -spfile]
    [Thread-4] [9:56:38:899] [Oradim.getEditEntryCommand:422] getEditEntry cmd=[D:\oracle\product\10.2.0\db_1\bin\oradim.exe, -edit, -sid, ORA10G, -startmode, auto, -srvcstart, system]
    [Thread-4] [9:56:39:55] [Oradim.addSidToRegistry:871] oracleHomeKey: SOFTWARE\ORACLE\KEY_OraDb10g_home1
    [Thread-4] [9:56:39:117] [BasicStep.configureSettings:304] messageHandler being set=oracle.sysman.assistants.util.UIMessageHandler@c73f0d8
    [Thread-4] [9:56:39:117] [CloneRmanRestoreStep.executeImpl:217] Instance Creation went fine..........
    [Thread-4] [9:56:39:117] [CloneRmanRestoreStep.executeImpl:224] db_recovery_file_dest=D:\oracle\product\10.2.0\flash_recovery_area
    [Thread-4] [9:56:39:117] [CloneRmanRestoreStep.executeImpl:227] db_recovery_file_dest_size=2147483648
    [Thread-4] [9:56:39:991] [SQLEngine.setSpool:1750] old Spool = null
    [Thread-4] [9:56:39:991] [SQLEngine.setSpool:1751] Setting Spool = D:\oracle\product\10.2.0\db_1\cfgtoollogs\dbca\ora10g\CloneRmanRestore.log
    [Thread-4] [9:56:39:991] [SQLEngine.setSpool:1752] Is spool appendable? --> true
    [Thread-4] [9:56:39:991] [CloneRmanRestoreStep.executeImpl:320] starting with pfile=D:\oracle\product\10.2.0\admin\ora10g\pfile\init.ora

    Check your SQLNET.AUTHENTICATION_SERVICES settings in sqlnet.ora file.
    ORA-28547 : Connection to server failed, probable Net8 admin error
    thanks
    http://swervedba.wordpress.com/

  • Oracle 11gR2 installation problem on Windows Server 2008 R2 datacenter

    Hi
    I am trying to install Oracle 11Gr2 64 bit on Windows server 2008 R2.The system configuration is "Intel Xeon, RAM 8.00 GB.
    i
    The installation is getting paused at the 8th step of Oracle installation.Neither i am getting any error message nor an entry is recorded in the Oracle inventory log.
    It is showing a blank screen after the prerequiste checks are complete.
    Request you to help me out in resolving the issue.
    Thanks in advance for your cooperation.

    Hi Helios
    Thanks for the response. The database is still not created to check in the Alert log .It is still in the phase of pre-requisite checks. I did not go with Silent installation.It is a plain single instance installation.
    The installation screen is greyed out with out any message or error.
    Please could you share if you have any thoughts on this.

  • Can't uninstall or reinstall oracle 10g express edition in windows server 2

    Hi,
    I need help from all of you, i already install oracle 10g express edition in windows server 2003 in D drive. but i can't remove because the oracle not in the add remove program so i download the windows install clean up to remove
    but after remove it still in the all program i still can start and stop the database but can't go to the database home page. can any one guide me to use command prompt to remove.
    Thanks

    Hi,
    I need help from all of you, i already install oracle 10g express edition in windows server 2003 in D drive. but i can't remove because the oracle not in the add remove program so i download the windows install clean up to remove
    but after remove it still in the all program i still can start and stop the database but can't go to the database home page. can any one guide me to use command prompt to remove.
    Thanks

  • Oracle ODBC version error on windows server 2008 64 bit

    We had installed oracle 10g standard edition on windows server 2008 64 bit. After one hour use of ODBC connection, we are getting a error message like 'Oracle client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed'
    Find the link for error message. http://www.google.co.in/imgres?newwindow=1&biw=1600&bih=1075&tbm=isch&tbnid=zc1Vas4O9Eqj4M:&imgrefurl=http://social.tech…
    Please give solution for the said issue. Thanks in advance.

    SAP said it is Oracle not support windows server 2008.

  • Export session key failed: 2148073482 in Window Server 2000 SP4

    I try to connect some database by ODBC connenction but when I click test on ODBC data source Administrator, It fails as error in Title
    But I try to connect in windows server 2003 , It can connect
    I don't know why windows server 2000 cannot
    Have you any suggect how to setting in windows server 2000?
    Thanks in advance

    Sorry to say, but Windows 2000 is out of life cycle
    http://support.microsoft.com/gp/lifean36
    Thank you for understanding
    Milos

  • Oracle DB 10g XE on Windows Server 2008 R2 64bit

    Hello to everybody!
    I have and old pc with Windows Server 2003 (32 bit) where i've installed Oracle DB 10g XE. Everything works fine.
    Now i have to migrate the DB from that old machine to a new one with Windows Server 2008 R2 64bit.
    I've tryied to install the Oracle DB 10g XE into the new server but, after installation is finished, i wasn't able to open the DB homepage at http://127.0.0.1:8080/apex. It said "This page can't be displayed". I try with SQLPLUS but after i insert the admin credentials i obtain these lines:
    ERROR:
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Where can be the problem?

    >> ORA-01034: ORACLE not available
    Database is not running. Most likely the installer did not complete all its tasks, it can happen.
    For windows, the database service has to be set up (see Start/Run/services.msc), services started, installer creates the database, and quite a few other setup chores. If the database creation fails, all the other stuff is not relevant.
    Under the <drive:>oraclexe folder there *should* be a datafiles (*.DBF) files somewhere. Can't recall the exact location for 10g. Try file explorer and a search for *.dbf files, that will probably come up empty.
    Note the requirements, at Oracle&amp;reg; Database Express Edition it calls for x86, not x64. The 11g XE also has lots of trouble getting a successful install on x64 as well, note the Download page states "does not work on x64" although some folks have gotten it to work.Try the deinstall steps, and use a right click/run as Administrator that *might* get past the UAC glitch that happens on the later OS versions.

  • Installation of Oracle 11g Release 2 on Windows Server 2008 R2

    Hi:
    When I tried to install 64-bit Oracle 11g Release 2 on a system running 64-bit Windows Server 2008 R2.
    One of the system pre-requisites failed with the following error message:
    Checking operating system requirements ...
    Expected result: One of 5.0,5.1,5.2,6.0
    Actual Result: 6.1
    Check complete. The overall result of this check is: Failed <<<<
    Problem: Oracle Database 11g is not certified on the current operating system.
    Recommendation: Make sure you are installing the software on the correct platform.
    I presume 6.0 is Windows 2008 Server and 6.1 should be Release 2.
    Does this mean that this version is not compatible with Server 2008 Release 2?
    venki
    Edited by: thevenkat on Jan 20, 2010 9:37 PM

    Hans Forbrich wrote:
    [email protected] wrote:
    Does anyone know when we can expect 11g R2 for Windows?No one outside of Oracle officially knows (and they are under NDA)
    No one inside Oracle is permitted to say, or pre-announce release dates for legal reasons.
    Which is why I gave you the link - so you could monitor for yourself.OK, thanks...
    I was just hoping there was an official release date and I just couldn't find it.
    Is there any information about features in 11gR2 for Windows available yet?
    Or can you maybe tell me if it will be possible to mount the new "database filesystem" like we can do on linux?
    I remember oracle did something similar with Oracle ifs (Internet File System) back in Oracle 9i. (or was it 8i?)
    Regards
    Thomas

  • Multiple Oracle Databases in a Single Windows Server

    Hi all,
    I have Windows Server System which has oracle database created.
    My question is:-
    How can i create multiple databases on the same server without affecting the first created database & i want to use the both databases at a time?
    Please give the steps to do multiple databases in the same server if possible..
    Thanks in advance,
    Venkatesh J

    Venkateshj wrote:
    How can i create multiple databases on the same server without affecting the first created database & i want to use the both databases at a time?Yes, possible. No, invariable a a bad idea as this is not a scalable approach.
    Oracle scales by adding more servers to a single physical database. This is called Oracle RAC.
    You want to add more physical databases to a single server - doing the exact opposite of what Oracle offers as a scalable solution.
    Please give the steps to do multiple databases in the same server if possible..No special steps. Run DBCA and create a new database instance. In other words, the exact same steps followed for creating the 1st database on that server.
    Also make sure you fully understand WHAT you are doing and the IMPLICATIONS of that. An Oracle database is not the same as a mySQL or SQL-Server database. An Oracle Schema is a logical database - and compares to what a mySQL/SQL-Server database is.
    And a single Oracle database can contain 1000s of logical databases (schemas). Each with their own dedicated storage, own security, own resource profile, etc.
    Oracle is not mySQL/SQL-Server.
    Understanding the differences is important.

  • SChannel Fails Authentication on Windows Server 2008 R2 Using TLS1

    I am trying to use SChannel to secure a socket connection. I modified the example at
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa380537(v=vs.85).aspx, converting it from Negotiate to SChannel.  Following the specs for the SSPI APIs I was able the get a Client & Server connection authenticated on Windows 7. 
    However, when I try running the same programs on Windows Server 2008 R2, either the Client side or Server side fails, depending on how I select the security protocol.
    Here is the modified example code, details about my results follow the code.
    Client.cpp
    // Client-side program to establish an SSPI socket connection
    // with a server and exchange messages.
    // Define macros and constants.
    #include "StdAfx.h"
    #include <windows.h>
    #include <winsock.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include "SspiExample.h"
    #include <string>
    #include <iostream>
    CredHandle g_hCred;
    SecHandle g_hCtext;
    #define SSPI_CLIENT "SChannelClient:" __FUNCTION__
    void main(int argc, char * argv[])
    SOCKET Client_Socket;
    BYTE Data[BIG_BUFF];
    PCHAR pMessage;
    WSADATA wsaData;
    SECURITY_STATUS ss;
    DWORD cbRead;
    ULONG cbHeader;
    ULONG cbMaxMessage;
    ULONG cbTrailer;
    SecPkgContext_StreamSizes SecPkgSizes;
    SecPkgContext_PackageInfo SecPkgPkgInfo;
    SecPkgContext_ConnectionInfo ConnectionInfo;
    BOOL DoAuthentication (SOCKET s, WCHAR * pCertName);
    char Server[512] = {0};
    WCHAR CertName[512] = {0};
    // Validate cmd line parameters
    if ( argc != 3 )
    LOGA ( ( __log_buf, SSPI_CLIENT " required parameters ServerName & CertName not entered.\n"));
    LOGA( ( __log_buf, SSPI_CLIENT " Abort and start over with required parameters.\n") );
    std::cin.get();
    else
    // argv[1] - ServerName - the name of the computer running the server sample.
    // argv[2] - TargetName the common name of the certificate provided
    // by the target server program.
    memcpy(Server, argv[1], strlen(argv[1]));
    size_t sizCN;
    mbstowcs_s(&sizCN, CertName, strlen(argv[2])+1, argv[2], _TRUNCATE);
    LOGA ( ( __log_buf, SSPI_CLIENT " input parameters - ServerName %s CertName %ls.\n", Server, CertName ));
    // Initialize the socket and the SSP security package.
    if(WSAStartup (0x0101, &wsaData))
    MyHandleError( __FUNCTION__ " Could not initialize winsock ");
    // Connect to a server.
    SecInvalidateHandle( &g_hCtext );
    if (!ConnectAuthSocket (
    &Client_Socket,
    &g_hCred,
    &g_hCtext,
    Server,
    CertName))
    MyHandleError( __FUNCTION__ " Authenticated server connection ");
    LOGA ( ( __log_buf, SSPI_CLIENT " connection authenticated.\n"));
    // An authenticated session with a server has been established.
    // Receive and manage a message from the server.
    // First, find and display the name of the SSP,
    // the transport protocol supported by the SSP,
    // and the size of the header, maximum message, and
    // trailer blocks for this SSP.
    ss = QueryContextAttributes(
    &g_hCtext,
    SECPKG_ATTR_PACKAGE_INFO,
    &SecPkgPkgInfo );
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_CLIENT "QueryContextAttributes failed: 0x%08x\n", ss));
    MyHandleError( __FUNCTION__ " QueryContextAttributes failed.\n");
    else
    LOGA ( ( __log_buf, SSPI_CLIENT " Package Name: %ls\n", SecPkgPkgInfo.PackageInfo->Name));
    // Free the allocated buffer.
    FreeContextBuffer(SecPkgPkgInfo.PackageInfo);
    ss = QueryContextAttributes(
    &g_hCtext,
    SECPKG_ATTR_STREAM_SIZES,
    &SecPkgSizes );
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_CLIENT " QueryContextAttributes failed: 0x%08x\n", ss));
    MyHandleError( __FUNCTION__ " Query context ");
    cbHeader = SecPkgSizes.cbHeader;
    cbMaxMessage = SecPkgSizes.cbMaximumMessage;
    cbTrailer = SecPkgSizes.cbTrailer;
    LOGA ( ( __log_buf, SSPI_CLIENT " cbHeader %u, cbMaxMessage %u, cbTrailer %u\n", cbHeader, cbMaxMessage, cbTrailer ));
    ss = QueryContextAttributes(
    &g_hCtext,
    SECPKG_ATTR_CONNECTION_INFO,
    &ConnectionInfo );
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_CLIENT " QueryContextAttributes failed: 0x%08x\n", ss));
    MyHandleError( __FUNCTION__ " Query context ");
    switch(ConnectionInfo.dwProtocol)
    case SP_PROT_TLS1_CLIENT:
    LOGA ( ( __log_buf, SSPI_CLIENT " Protocol: TLS1\n"));
    break;
    case SP_PROT_SSL3_CLIENT:
    LOGA ( ( __log_buf, SSPI_CLIENT " Protocol: SSL3\n"));
    break;
    case SP_PROT_PCT1_CLIENT:
    LOGA ( ( __log_buf, SSPI_CLIENT " Protocol: PCT\n"));
    break;
    case SP_PROT_SSL2_CLIENT:
    LOGA ( ( __log_buf, SSPI_CLIENT " Protocol: SSL2\n"));
    break;
    default:
    LOGA ( ( __log_buf, SSPI_CLIENT " Unknown Protocol: 0x%x\n", ConnectionInfo.dwProtocol));
    switch(ConnectionInfo.aiCipher)
    case CALG_RC4:
    LOGA ( ( __log_buf, SSPI_CLIENT " Cipher: RC4\n");)
    break;
    case CALG_3DES:
    LOGA ( ( __log_buf, SSPI_CLIENT " Cipher: Triple DES\n"));
    break;
    case CALG_RC2:
    LOGA ( ( __log_buf, SSPI_CLIENT " Cipher: RC2\n"));
    break;
    case CALG_DES:
    case CALG_CYLINK_MEK:
    LOGA ( ( __log_buf, SSPI_CLIENT " Cipher: DES\n"));
    break;
    case CALG_SKIPJACK:
    LOGA ( ( __log_buf, SSPI_CLIENT " Cipher: Skipjack\n"));
    break;
    case CALG_AES_256:
    LOGA ( ( __log_buf, SSPI_CLIENT " Cipher: AES 256\n"));
    break;
    default:
    LOGA ( ( __log_buf, SSPI_CLIENT " Unknown Cipher: 0x%x\n", ConnectionInfo.aiCipher));
    LOGA ( ( __log_buf, SSPI_CLIENT " Cipher strength: %d\n", ConnectionInfo.dwCipherStrength));
    switch(ConnectionInfo.aiHash)
    case CALG_MD5:
    LOGA ( ( __log_buf, SSPI_CLIENT " Hash: MD5\n"));
    break;
    case CALG_SHA:
    LOGA ( ( __log_buf, SSPI_CLIENT " Hash: SHA\n"));
    break;
    default:
    LOGA ( ( __log_buf, SSPI_CLIENT " Unknown Hash: 0x%x\n", ConnectionInfo.aiHash));
    LOGA ( ( __log_buf, SSPI_CLIENT " Hash strength: %d\n", ConnectionInfo.dwHashStrength));
    switch(ConnectionInfo.aiExch)
    case CALG_RSA_KEYX:
    case CALG_RSA_SIGN:
    LOGA ( ( __log_buf, SSPI_CLIENT " Key exchange: RSA\n"));
    break;
    case CALG_KEA_KEYX:
    LOGA ( ( __log_buf, SSPI_CLIENT " Key exchange: KEA\n"));
    break;
    case CALG_DH_EPHEM:
    LOGA ( ( __log_buf, SSPI_CLIENT " Key exchange: DH Ephemeral\n"));
    break;
    default:
    LOGA ( ( __log_buf, SSPI_CLIENT " Unknown Key exchange: 0x%x\n", ConnectionInfo.aiExch));
    LOGA ( ( __log_buf, SSPI_CLIENT " Key exchange strength: %d\n", ConnectionInfo.dwExchStrength));
    // Decrypt and display the message from the server.
    if (!ReceiveBytes(
    Client_Socket,
    Data,
    BIG_BUFF,
    &cbRead))
    MyHandleError( __FUNCTION__ " No response from server\n");
    if (0 == cbRead)
    MyHandleError(__FUNCTION__ " Zero bytes received.\n");
    pMessage = (PCHAR) DecryptThis(
    Data,
    &cbRead,
    &g_hCtext);
    // Skip the header to get the decrypted message
    pMessage += cbHeader;
    ULONG cbMessage = cbRead-cbHeader-cbTrailer;
    if ((cbMessage == strlen(TEST_MSG)) &&
    !strncmp(pMessage, TEST_MSG, strlen(TEST_MSG)) )
    LOGA ( ( __log_buf, SSPI_CLIENT " SUCCESS!! The message from the server is \n -> %.*s \n",
    cbMessage, pMessage ))
    else
    LOGA ( ( __log_buf, SSPI_CLIENT " UNEXPECTED message from the server: \n -> %.*s \n",
    cbMessage, pMessage ));
    LOGA ( ( __log_buf, SSPI_CLIENT " rcvd msg size %u, exp size %u\n", cbMessage, strlen(TEST_MSG) ));
    // Terminate socket and security package.
    DeleteSecurityContext (&g_hCtext);
    FreeCredentialHandle (&g_hCred);
    shutdown (Client_Socket, 2);
    closesocket (Client_Socket);
    if (SOCKET_ERROR == WSACleanup ())
    MyHandleError( __FUNCTION__ " Problem with socket cleanup ");
    exit (EXIT_SUCCESS);
    } // end main
    // ConnectAuthSocket establishes an authenticated socket connection
    // with a server and initializes needed security package resources.
    BOOL ConnectAuthSocket (
    SOCKET *s,
    CredHandle *g_hCred,
    PSecHandle phCtext,
    char * pServer,
    WCHAR * pCertName)
    unsigned long ulAddress;
    struct hostent *pHost;
    SOCKADDR_IN sin;
    // Lookup the server's address.
    LOGA ( ( __log_buf, SSPI_CLIENT " entry.\n"));
    ulAddress = inet_addr (pServer);
    if (INADDR_NONE == ulAddress)
    LOGA ( ( __log_buf, SSPI_CLIENT " calling gethostbyname with %s.\n", pServer ));
    pHost = gethostbyname (pServer);
    if (NULL == pHost)
    MyHandleError(__FUNCTION__ " Unable to resolve host name ");
    memcpy((char FAR *)&ulAddress, pHost->h_addr, pHost->h_length);
    std::string ipAddrStr;
    ipAddrStr = inet_ntoa( *(struct in_addr*)*pHost->h_addr_list);
    LOGA ( ( __log_buf, __FUNCTION__ " gethostbyname - ipAddress %s, name %s.\n", ipAddrStr.c_str(), pHost->h_name ) );
    // Create the socket.
    *s = socket (
    PF_INET,
    SOCK_STREAM,
    0);
    if (INVALID_SOCKET == *s)
    MyHandleError(__FUNCTION__ " Unable to create socket");
    else
    LOGA ( ( __log_buf, SSPI_CLIENT " Socket created.\n"));
    sin.sin_family = AF_INET;
    sin.sin_addr.s_addr = ulAddress;
    sin.sin_port = htons (g_usPort);
    // Connect to the server.
    if (connect (*s, (LPSOCKADDR) &sin, sizeof (sin)))
    closesocket (*s);
    MyHandleError( __FUNCTION__ " Connect failed ");
    LOGA ( ( __log_buf, SSPI_CLIENT " Connection established.\n"));
    // Authenticate the connection.
    if (!DoAuthentication (*s, pCertName))
    closesocket (*s);
    MyHandleError( __FUNCTION__ " Authentication ");
    LOGA ( ( __log_buf, SSPI_CLIENT " success.\n"));
    return(TRUE);
    } // end ConnectAuthSocket
    BOOL DoAuthentication (SOCKET s, WCHAR * pCertName)
    BOOL fDone = FALSE;
    DWORD cbOut = 0;
    DWORD cbIn = 0;
    PBYTE pInBuf;
    PBYTE pOutBuf;
    if(!(pInBuf = (PBYTE) malloc(MAXMESSAGE)))
    MyHandleError( __FUNCTION__ " Memory allocation ");
    if(!(pOutBuf = (PBYTE) malloc(MAXMESSAGE)))
    MyHandleError( __FUNCTION__ " Memory allocation ");
    cbOut = MAXMESSAGE;
    LOGA ( ( __log_buf, SSPI_CLIENT " 1st message.\n"));
    if (!GenClientContext (
    NULL,
    0,
    pOutBuf,
    &cbOut,
    &fDone,
    pCertName,
    &g_hCred,
    &g_hCtext
    LOGA ( ( __log_buf, SSPI_CLIENT " GenClientContext failed\n"));
    return(FALSE);
    if (!SendMsg (s, pOutBuf, cbOut ))
    MyHandleError(__FUNCTION__ " Send message failed ");
    while (!fDone)
    if (!ReceiveMsg (
    s,
    pInBuf,
    MAXMESSAGE,
    &cbIn))
    MyHandleError( __FUNCTION__ " Receive message failed ");
    cbOut = MAXMESSAGE;
    LOGA ( ( __log_buf, SSPI_CLIENT " Message loop.\n"));
    if (!GenClientContext (
    pInBuf,
    cbIn,
    pOutBuf,
    &cbOut,
    &fDone,
    pCertName,
    &g_hCred,
    &g_hCtext))
    MyHandleError( __FUNCTION__ " GenClientContext failed");
    if (!SendMsg (
    s,
    pOutBuf,
    cbOut))
    MyHandleError( __FUNCTION__ " Send message failed");
    LOGA ( ( __log_buf, SSPI_CLIENT " fDone %s.\n", fDone ? "Yes" : "No" ));
    if (NULL != pInBuf)
    free(pInBuf);
    pInBuf = NULL;
    if (NULL != pOutBuf)
    free(pOutBuf);
    pOutBuf = NULL;
    LOGA ( ( __log_buf, SSPI_CLIENT " exit.\n"));
    return(TRUE);
    BOOL GenClientContext (
    BYTE *pIn,
    DWORD cbIn,
    BYTE *pOut,
    DWORD *pcbOut,
    BOOL *pfDone,
    WCHAR *pCertName,
    CredHandle *g_hCred,
    struct _SecHandle *g_hCtext)
    SECURITY_STATUS ss;
    TimeStamp Lifetime;
    SecBufferDesc OutBuffDesc;
    SecBuffer OutSecBuff;
    SecBufferDesc InBuffDesc;
    SecBuffer InSecBuff[2];
    ULONG ContextAttributes;
    static TCHAR lpPackageName[1024];
    if( NULL == pIn )
    wcscpy_s(lpPackageName, 1024 * sizeof(TCHAR), UNISP_NAME );
    ss = AcquireCredentialsHandle (
    NULL,
    lpPackageName,
    SECPKG_CRED_OUTBOUND,
    NULL,
    NULL,
    NULL,
    NULL,
    g_hCred,
    &Lifetime);
    if (!(SEC_SUCCESS (ss)))
    MyHandleError( __FUNCTION__ " AcquireCreds failed ");
    // Prepare the buffers.
    OutBuffDesc.ulVersion = 0;
    OutBuffDesc.cBuffers = 1;
    OutBuffDesc.pBuffers = &OutSecBuff;
    OutSecBuff.cbBuffer = *pcbOut;
    OutSecBuff.BufferType = SECBUFFER_TOKEN;
    OutSecBuff.pvBuffer = pOut;
    // The input buffer is created only if a message has been received
    // from the server.
    if (pIn)
    LOGA ( ( __log_buf, SSPI_CLIENT " Call InitializeSecurityContext with pIn supplied.\n"));
    InBuffDesc.ulVersion = 0;
    InBuffDesc.cBuffers = 1;
    InBuffDesc.pBuffers = InSecBuff;
    InSecBuff[0].cbBuffer = cbIn;
    InSecBuff[0].BufferType = SECBUFFER_TOKEN;
    InSecBuff[0].pvBuffer = pIn;
    InSecBuff[1].pvBuffer = NULL;
    InSecBuff[1].cbBuffer = 0;
    InSecBuff[1].BufferType = SECBUFFER_EMPTY;
    ss = InitializeSecurityContext (
    g_hCred,
    g_hCtext,
    pCertName,
    MessageAttribute,
    0,
    0,
    &InBuffDesc,
    0,
    g_hCtext,
    &OutBuffDesc,
    &ContextAttributes,
    &Lifetime);
    else
    LOGA ( ( __log_buf, SSPI_CLIENT " Call InitializeSecurityContext with NULL pIn.\n"));
    ss = InitializeSecurityContext (
    g_hCred,
    NULL,
    pCertName,
    MessageAttribute,
    0,
    0,
    NULL,
    0,
    g_hCtext,
    &OutBuffDesc,
    &ContextAttributes,
    &Lifetime);
    if (!SEC_SUCCESS (ss))
    LOGA ( ( __log_buf, SSPI_CLIENT " InitializeSecurityContext failed with error 0x%08x\n", ss));
    MyHandleError ( __FUNCTION__ " InitializeSecurityContext failed " );
    LOGA ( ( __log_buf, SSPI_CLIENT " InitializeSecurityContext returned 0x%08x\n", ss));
    // If necessary, complete the token.
    if ((SEC_I_COMPLETE_NEEDED == ss)
    || (SEC_I_COMPLETE_AND_CONTINUE == ss))
    ss = CompleteAuthToken (g_hCtext, &OutBuffDesc);
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_CLIENT " complete failed: 0x%08x\n", ss));
    return FALSE;
    *pcbOut = OutSecBuff.cbBuffer;
    *pfDone = !((SEC_I_CONTINUE_NEEDED == ss) ||
    (SEC_I_COMPLETE_AND_CONTINUE == ss));
    LOGA ( ( __log_buf, SSPI_CLIENT " Token buffer generated (%lu bytes):\n", OutSecBuff.cbBuffer));
    PrintHexDump (OutSecBuff.cbBuffer, (PBYTE)OutSecBuff.pvBuffer);
    return TRUE;
    PBYTE DecryptThis(
    PBYTE pBuffer,
    LPDWORD pcbMessage,
    struct _SecHandle *hCtxt)
    SECURITY_STATUS ss;
    SecBufferDesc BuffDesc;
    SecBuffer SecBuff[4];
    ULONG ulQop = 0;
    // By agreement, the server encrypted the message and set the size
    // of the trailer block to be just what it needed. DecryptMessage
    // needs the size of the trailer block.
    // The size of the trailer is in the first DWORD of the
    // message received.
    LOGA ( ( __log_buf, SSPI_CLIENT " data before decryption including trailer (%lu bytes):\n",
    *pcbMessage));
    PrintHexDump (*pcbMessage, (PBYTE) pBuffer);
    // Prepare the buffers to be passed to the DecryptMessage function.
    BuffDesc.ulVersion = 0;
    BuffDesc.cBuffers = 4;
    BuffDesc.pBuffers = SecBuff;
    SecBuff[0].cbBuffer = *pcbMessage;
    SecBuff[0].BufferType = SECBUFFER_DATA;
    SecBuff[0].pvBuffer = pBuffer;
    SecBuff[1].cbBuffer = 0;
    SecBuff[1].BufferType = SECBUFFER_EMPTY;
    SecBuff[1].pvBuffer = NULL;
    SecBuff[2].cbBuffer = 0;
    SecBuff[2].BufferType = SECBUFFER_EMPTY;
    SecBuff[2].pvBuffer = NULL;
    SecBuff[3].cbBuffer = 0;
    SecBuff[3].BufferType = SECBUFFER_EMPTY;
    SecBuff[3].pvBuffer = NULL;
    ss = DecryptMessage(
    hCtxt,
    &BuffDesc,
    0,
    &ulQop);
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_CLIENT " DecryptMessage failed with error 0x%08x\n", ss))
    else
    LOGA ( ( __log_buf, SSPI_CLIENT " DecryptMessage success? Status: 0x%08x\n", ss));
    // Return a pointer to the decrypted data. The trailer data
    // is discarded.
    return pBuffer;
    PBYTE VerifyThis(
    PBYTE pBuffer,
    LPDWORD pcbMessage,
    struct _SecHandle *hCtxt,
    ULONG cbMaxSignature)
    SECURITY_STATUS ss;
    SecBufferDesc BuffDesc;
    SecBuffer SecBuff[2];
    ULONG ulQop = 0;
    PBYTE pSigBuffer;
    PBYTE pDataBuffer;
    // The global cbMaxSignature is the size of the signature
    // in the message received.
    LOGA ( ( __log_buf, SSPI_CLIENT " data before verifying (including signature):\n"));
    PrintHexDump (*pcbMessage, pBuffer);
    // By agreement with the server,
    // the signature is at the beginning of the message received,
    // and the data that was signed comes after the signature.
    pSigBuffer = pBuffer;
    pDataBuffer = pBuffer + cbMaxSignature;
    // The size of the message is reset to the size of the data only.
    *pcbMessage = *pcbMessage - (cbMaxSignature);
    // Prepare the buffers to be passed to the signature verification
    // function.
    BuffDesc.ulVersion = 0;
    BuffDesc.cBuffers = 2;
    BuffDesc.pBuffers = SecBuff;
    SecBuff[0].cbBuffer = cbMaxSignature;
    SecBuff[0].BufferType = SECBUFFER_TOKEN;
    SecBuff[0].pvBuffer = pSigBuffer;
    SecBuff[1].cbBuffer = *pcbMessage;
    SecBuff[1].BufferType = SECBUFFER_DATA;
    SecBuff[1].pvBuffer = pDataBuffer;
    ss = VerifySignature(
    hCtxt,
    &BuffDesc,
    0,
    &ulQop
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_CLIENT " VerifyMessage failed with error 0x%08x\n", ss));
    else
    LOGA ( ( __log_buf, SSPI_CLIENT " Message was properly signed.\n"));
    return pDataBuffer;
    } // end VerifyThis
    void PrintHexDump(
    DWORD length,
    PBYTE buffer)
    DWORD i,count,index;
    CHAR rgbDigits[]="0123456789abcdef";
    CHAR rgbLine[100];
    char cbLine;
    for(index = 0; length;
    length -= count, buffer += count, index += count)
    count = (length > 16) ? 16:length;
    sprintf_s(rgbLine, 100, "%4.4x ",index);
    cbLine = 6;
    for(i=0;i<count;i++)
    rgbLine[cbLine++] = rgbDigits[buffer[i] >> 4];
    rgbLine[cbLine++] = rgbDigits[buffer[i] & 0x0f];
    if(i == 7)
    rgbLine[cbLine++] = ':';
    else
    rgbLine[cbLine++] = ' ';
    for(; i < 16; i++)
    rgbLine[cbLine++] = ' ';
    rgbLine[cbLine++] = ' ';
    rgbLine[cbLine++] = ' ';
    rgbLine[cbLine++] = ' ';
    for(i = 0; i < count; i++)
    if(buffer[i] < 32 || buffer[i] > 126)
    rgbLine[cbLine++] = '.';
    else
    rgbLine[cbLine++] = buffer[i];
    rgbLine[cbLine++] = 0;
    LOGA ( ( __log_buf, SSPI_CLIENT " %s\n", rgbLine));
    BOOL SendMsg (
    SOCKET s,
    PBYTE pBuf,
    DWORD cbBuf)
    if (0 == cbBuf)
    return(TRUE);
    // Send the size of the message.
    LOGA ( ( __log_buf, SSPI_CLIENT " %lu bytes\n", cbBuf ));
    if (!SendBytes (s, (PBYTE)&cbBuf, sizeof (cbBuf)))
    LOGA ( ( __log_buf, SSPI_CLIENT " size failed.\n" ) );
    return(FALSE);
    // Send the body of the message.
    if (!SendBytes (
    s,
    pBuf,
    cbBuf))
    LOGA ( ( __log_buf, SSPI_CLIENT " body failed.\n" ) );
    return(FALSE);
    LOGA ( ( __log_buf, SSPI_CLIENT " success\n" ) );
    return(TRUE);
    BOOL ReceiveMsg (
    SOCKET s,
    PBYTE pBuf,
    DWORD cbBuf,
    DWORD *pcbRead)
    DWORD cbRead;
    DWORD cbData;
    // Receive the number of bytes in the message.
    LOGA ( ( __log_buf, SSPI_CLIENT " entry.\n" ));
    if (!ReceiveBytes (
    s,
    (PBYTE)&cbData,
    sizeof (cbData),
    &cbRead))
    return(FALSE);
    if (sizeof (cbData) != cbRead)
    LOGA ( ( __log_buf, SSPI_CLIENT " failed: size of cbData %lu, bytes %lu\n", sizeof (cbData), cbRead));
    return(FALSE);
    // Read the full message.
    if (!ReceiveBytes (
    s,
    pBuf,
    cbData,
    &cbRead))
    return(FALSE);
    if (cbRead != cbData)
    return(FALSE);
    *pcbRead = cbRead;
    return(TRUE);
    } // end ReceiveMessage
    BOOL SendBytes (
    SOCKET s,
    PBYTE pBuf,
    DWORD cbBuf)
    PBYTE pTemp = pBuf;
    int cbSent;
    int cbRemaining = cbBuf;
    if (0 == cbBuf)
    return(TRUE);
    while (cbRemaining)
    LOGA ( ( __log_buf, SSPI_CLIENT " %lu bytes.\n", cbRemaining ));
    cbSent = send (
    s,
    (const char *)pTemp,
    cbRemaining,
    0);
    if (SOCKET_ERROR == cbSent)
    LOGA ( ( __log_buf, SSPI_CLIENT " send failed: 0x%08.8X\n", GetLastError ()));
    return FALSE;
    pTemp += cbSent;
    cbRemaining -= cbSent;
    LOGA ( ( __log_buf, SSPI_CLIENT " success\n" ) );
    return TRUE;
    BOOL ReceiveBytes (
    SOCKET s,
    PBYTE pBuf,
    DWORD cbBuf,
    DWORD *pcbRead)
    PBYTE pTemp = pBuf;
    int cbRead, cbRemaining = cbBuf;
    LOGA ( ( __log_buf, SSPI_CLIENT " Entry: %lu bytes.\n", cbRemaining ));
    while (cbRemaining)
    cbRead = recv (
    s,
    (char *)pTemp,
    cbRemaining,
    0);
    LOGA ( ( __log_buf, SSPI_CLIENT " %lu bytes remaining.\n", cbRemaining ));
    if (0 == cbRead)
    break;
    if (SOCKET_ERROR == cbRead)
    LOGA ( ( __log_buf, SSPI_CLIENT " recv failed: 0x%08.8X\n", GetLastError ()));
    return FALSE;
    cbRemaining -= cbRead;
    pTemp += cbRead;
    *pcbRead = cbBuf - cbRemaining;
    LOGA ( ( __log_buf, SSPI_CLIENT " success.\n" ));
    return TRUE;
    } // end ReceiveBytes
    void MyHandleError(char *s)
    DWORD err = GetLastError();
    if (err)
    LOGA ( ( __log_buf, SSPI_CLIENT " %s error (0x%08.8X). Exiting.\n",s, err ))
    else
    LOGA ( ( __log_buf, SSPI_CLIENT " %s error (no error info). Exiting.\n",s ));
    exit (EXIT_FAILURE);
    Server.cpp
    // This is a server-side SSPI Windows Sockets program.
    #include "StdAfx.h"
    #include <windows.h>
    #include <winsock.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include "Sspiexample.h"
    #include <iostream>
    CredHandle g_hcred;
    struct _SecHandle g_hctxt;
    static PBYTE g_pInBuf = NULL;
    static PBYTE g_pOutBuf = NULL;
    static DWORD g_cbMaxMessage;
    static TCHAR g_lpPackageName[1024];
    BOOL AcceptAuthSocket (SOCKET *ServerSocket, std::string certThumb );
    #define SSPI_SERVER "SChannelServer:" __FUNCTION__
    void main (int argc, char * argv[])
    CHAR pMessage[200];
    DWORD cbMessage;
    PBYTE pDataToClient = NULL;
    DWORD cbDataToClient = 0;
    PWCHAR pUserName = NULL;
    DWORD cbUserName = 0;
    SOCKET Server_Socket;
    WSADATA wsaData;
    SECURITY_STATUS ss;
    PSecPkgInfo pkgInfo;
    SecPkgContext_StreamSizes SecPkgSizes;
    SecPkgContext_PackageInfo SecPkgPkgInfo;
    ULONG cbMaxMessage;
    ULONG cbHeader;
    ULONG cbTrailer;
    std::string certThumb;
    // Create a certificate if no thumbprint is supplied. Otherwise, use the provided
    // thumbprint to find the certificate.
    if ( (argc > 1) && (strlen( argv[1]) > 0) )
    certThumb.assign(argv[1]);
    else
    LOGA( ( __log_buf, SSPI_SERVER " : No certificate thumbprint supplied.\n") );
    LOGA( ( __log_buf, SSPI_SERVER " : Press ENTER to create a certificate, or abort and start over with a thumbprint.\n") );
    std::cin.get();
    certThumb.clear();
    Insert code to find or create X.509 certificate.
    // Set the default package to SChannel.
    wcscpy_s(g_lpPackageName, 1024 * sizeof(TCHAR), UNISP_NAME);
    // Initialize the socket interface and the security package.
    if( WSAStartup (0x0101, &wsaData))
    LOGA ( ( __log_buf, SSPI_SERVER " Could not initialize winsock: \n") );
    cleanup();
    ss = QuerySecurityPackageInfo (
    g_lpPackageName,
    &pkgInfo);
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_SERVER " Could not query package info for %s, error 0x%08x\n",
    g_lpPackageName, ss) );
    cleanup();
    g_cbMaxMessage = pkgInfo->cbMaxToken;
    FreeContextBuffer(pkgInfo);
    g_pInBuf = (PBYTE) malloc (g_cbMaxMessage);
    g_pOutBuf = (PBYTE) malloc (g_cbMaxMessage);
    if (NULL == g_pInBuf || NULL == g_pOutBuf)
    LOGA ( ( __log_buf, SSPI_SERVER " Memory allocation error.\n"));
    cleanup();
    // Start looping for clients.
    while(TRUE)
    LOGA ( ( __log_buf, SSPI_SERVER " Waiting for client to connect...\n"));
    // Make an authenticated connection with client.
    if (!AcceptAuthSocket (&Server_Socket, certThumb ))
    LOGA ( ( __log_buf, SSPI_SERVER " Could not authenticate the socket.\n"));
    cleanup();
    ss = QueryContextAttributes(
    &g_hctxt,
    SECPKG_ATTR_STREAM_SIZES,
    &SecPkgSizes );
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_SERVER " failed: 0x%08x\n", ss));
    exit(1);
    // The following values are used for encryption and signing.
    cbMaxMessage = SecPkgSizes.cbMaximumMessage;
    cbHeader = SecPkgSizes.cbHeader;
    cbTrailer = SecPkgSizes.cbTrailer;
    LOGA ( ( __log_buf, SSPI_SERVER " cbHeader %u, cbMaxMessage %u, cbTrailer %u\n", cbHeader, cbMaxMessage, cbTrailer ));
    ss = QueryContextAttributes(
    &g_hctxt,
    SECPKG_ATTR_PACKAGE_INFO,
    &SecPkgPkgInfo );
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_SERVER " failed: 0x%08x\n", ss));
    exit(1);
    else
    LOGA ( ( __log_buf, SSPI_SERVER " Package Name: %ls\n", SecPkgPkgInfo.PackageInfo->Name));
    // Free the allocated buffer.
    FreeContextBuffer(SecPkgPkgInfo.PackageInfo);
    // Send the client an encrypted message.
    strcpy_s(pMessage, sizeof(pMessage),
    TEST_MSG);
    cbMessage = (DWORD)strlen(pMessage);
    EncryptThis (
    (PBYTE) pMessage,
    cbMessage,
    &pDataToClient,
    &cbDataToClient,
    cbHeader,
    cbTrailer);
    // Send the encrypted data to client.
    if (!SendBytes(
    Server_Socket,
    pDataToClient,
    cbDataToClient))
    LOGA ( ( __log_buf, SSPI_SERVER " send message failed. \n"));
    cleanup();
    LOGA ( ( __log_buf, SSPI_SERVER " %d encrypted bytes sent. \n", cbDataToClient));
    if (Server_Socket)
    DeleteSecurityContext (&g_hctxt);
    FreeCredentialHandle (&g_hcred);
    shutdown (Server_Socket, 2) ;
    closesocket (Server_Socket);
    Server_Socket = 0;
    if (pUserName)
    free (pUserName);
    pUserName = NULL;
    cbUserName = 0;
    if(pDataToClient)
    free (pDataToClient);
    pDataToClient = NULL;
    cbDataToClient = 0;
    } // end while loop
    LOGA ( ( __log_buf, SSPI_SERVER " Server ran to completion without error.\n"));
    cleanup();
    } // end main
    BOOL AcceptAuthSocket (SOCKET *ServerSocket, std::string certThumb )
    SOCKET sockListen;
    SOCKET sockClient;
    SOCKADDR_IN sockIn;
    // Create listening socket.
    sockListen = socket (
    PF_INET,
    SOCK_STREAM,
    0);
    if (INVALID_SOCKET == sockListen)
    LOGA ( ( __log_buf, SSPI_SERVER " Failed to create socket: %u\n", GetLastError ()));
    return(FALSE);
    // Bind to local port.
    sockIn.sin_family = AF_INET;
    sockIn.sin_addr.s_addr = 0;
    sockIn.sin_port = htons(usPort);
    if (SOCKET_ERROR == bind (
    sockListen,
    (LPSOCKADDR) &sockIn,
    sizeof (sockIn)))
    LOGA ( ( __log_buf, SSPI_SERVER " bind failed: %u\n", GetLastError ()));
    return(FALSE);
    // Listen for client.
    if (SOCKET_ERROR == listen (sockListen, 1))
    LOGA ( ( __log_buf, SSPI_SERVER " Listen failed: %u\n", GetLastError ()));
    return(FALSE);
    else
    LOGA ( ( __log_buf, SSPI_SERVER " Listening ! \n"));
    // Accept client.
    sockClient = accept (
    sockListen,
    NULL,
    NULL);
    if (INVALID_SOCKET == sockClient)
    LOGA ( ( __log_buf, SSPI_SERVER " accept failed: %u\n",GetLastError() ) );
    return(FALSE);
    closesocket (sockListen);
    *ServerSocket = sockClient;
    return(DoAuthentication (sockClient, certThumb ));
    } // end AcceptAuthSocket
    BOOL DoAuthentication (SOCKET AuthSocket, std::string certThumb )
    SECURITY_STATUS ss;
    DWORD cbIn, cbOut;
    BOOL done = FALSE;
    TimeStamp Lifetime;
    BOOL fNewConversation;
    fNewConversation = TRUE;
    PCCERT_CONTEXT pCertCtxt;
    Insert code to retrieve pCertCtxt
    // Build SCHANNEL_CRED structure to hold CERT_CONTEXT for call to AcquireCredentialsHandle
    SCHANNEL_CRED credSchannel = {0};
    credSchannel.dwVersion = SCHANNEL_CRED_VERSION;
    credSchannel.grbitEnabledProtocols = SP_PROT_SSL2_SERVER | SP_PROT_TLS1_SERVER;
    credSchannel.cCreds = 1;
    credSchannel.paCred = &pCertCtxt;
    ss = AcquireCredentialsHandle (
    NULL, //pszPrincipal
    g_lpPackageName, //pszPackage
    SECPKG_CRED_INBOUND, //fCredentialuse
    NULL, //pvLogonID
    &credSchannel, //pAuthData - need SCHANNEL_CRED structure that indicates the protocol to use and the settings for various customizable channel features.
    NULL, //pGetKeyFn
    NULL, //pvGetKeyArgument
    &g_hcred, //phCredential
    &Lifetime); //ptsExpiry
    if (!SEC_SUCCESS (ss))
    LOGA ( ( __log_buf, SSPI_SERVER " AcquireCreds failed: 0x%08x\n", ss));
    return(FALSE);
    while(!done)
    if (!ReceiveMsg (
    AuthSocket,
    g_pInBuf,
    g_cbMaxMessage,
    &cbIn))
    return(FALSE);
    cbOut = g_cbMaxMessage;
    if (!GenServerContext (
    g_pInBuf,
    cbIn,
    g_pOutBuf,
    &cbOut,
    &done,
    fNewConversation))
    LOGA ( ( __log_buf, SSPI_SERVER " GenServerContext failed.\n"));
    return(FALSE);
    fNewConversation = FALSE;
    if (!SendMsg (
    AuthSocket,
    g_pOutBuf,
    cbOut))
    LOGA ( ( __log_buf, SSPI_SERVER " Send message failed.\n"));
    return(FALSE);
    return(TRUE);
    } // end DoAuthentication
    BOOL GenServerContext (
    BYTE *pIn,
    DWORD cbIn,
    BYTE *pOut,
    DWORD *pcbOut,
    BOOL *pfDone,
    BOOL fNewConversation)
    SECURITY_STATUS ss;
    TimeStamp Lifetime;
    SecBufferDesc OutBuffDesc;
    SecBuffer OutSecBuff;
    SecBufferDesc InBuffDesc;
    SecBuffer InSecBuff;
    ULONG Attribs = 0;
    // Prepare output buffers.
    OutBuffDesc.ulVersion = 0;
    OutBuffDesc.cBuffers = 1;
    OutBuffDesc.pBuffers = &OutSecBuff;
    OutSecBuff.cbBuffer = *pcbOut;
    OutSecBuff.BufferType = SECBUFFER_TOKEN;
    OutSecBuff.pvBuffer = pOut;
    // Prepare input buffers.
    InBuffDesc.ulVersion = 0;
    InBuffDesc.cBuffers = 1;
    InBuffDesc.pBuffers = &InSecBuff;
    InSecBuff.cbBuffer = cbIn;
    InSecBuff.BufferType = SECBUFFER_TOKEN;
    InSecBuff.pvBuffer = pIn;
    LOGA ( ( __log_buf, SSPI_SERVER " Token buffer received (%lu bytes):\n", InSecBuff.cbBuffer));
    PrintHexDump (InSecBuff.cbBuffer, (PBYTE)InSecBuff.pvBuffer);
    ss = AcceptSecurityContext (
    &g_hcred,
    fNewConversation ? NULL : &g_hctxt,
    &InBuffDesc,
    Attribs,
    SECURITY_NATIVE_DREP,
    &g_hctxt,
    &OutBuffDesc,
    &Attribs,
    &Lifetime);
    if (!SEC_SUCCESS (ss))
    LOGA ( ( __log_buf, SSPI_SERVER " AcceptSecurityContext failed: 0x%08x\n", ss));
    OutputDebugStringA( "." );
    return FALSE;
    // Complete token if applicable.
    if ((SEC_I_COMPLETE_NEEDED == ss)
    || (SEC_I_COMPLETE_AND_CONTINUE == ss))
    ss = CompleteAuthToken (&g_hctxt, &OutBuffDesc);
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_SERVER " complete failed: 0x%08x\n", ss));
    OutputDebugStringA( "." );
    return FALSE;
    *pcbOut = OutSecBuff.cbBuffer;
    // fNewConversation equals FALSE.
    LOGA ( ( __log_buf, SSPI_SERVER " Token buffer generated (%lu bytes):\n",
    OutSecBuff.cbBuffer));
    PrintHexDump (
    OutSecBuff.cbBuffer,
    (PBYTE)OutSecBuff.pvBuffer);
    *pfDone = !((SEC_I_CONTINUE_NEEDED == ss)
    || (SEC_I_COMPLETE_AND_CONTINUE == ss));
    LOGA ( ( __log_buf, SSPI_SERVER " AcceptSecurityContext result = 0x%08x\n", ss));
    return TRUE;
    } // end GenServerContext
    BOOL EncryptThis (
    PBYTE pMessage,
    ULONG cbMessage,
    BYTE ** ppOutput,
    ULONG * pcbOutput,
    ULONG cbHeader,
    ULONG cbTrailer)
    SECURITY_STATUS ss;
    SecBufferDesc BuffDesc;
    SecBuffer SecBuff[4];
    ULONG ulQop = 0;
    // The size of the trailer (signature + padding) block is
    // determined from the global cbSecurityTrailer.
    LOGA ( ( __log_buf, SSPI_SERVER " Data before encryption: %s\n", pMessage));
    LOGA ( ( __log_buf, SSPI_SERVER " Length of data before encryption: %d \n",cbMessage));
    // Prepare buffers.
    BuffDesc.ulVersion = 0;
    BuffDesc.cBuffers = 4;
    BuffDesc.pBuffers = SecBuff;
    PBYTE pHeader;
    pHeader = (PBYTE) malloc (cbHeader);
    SecBuff[0].cbBuffer = cbHeader;
    SecBuff[0].BufferType = SECBUFFER_STREAM_HEADER;
    SecBuff[0].pvBuffer = pHeader;
    SecBuff[1].cbBuffer = cbMessage;
    SecBuff[1].BufferType = SECBUFFER_DATA;
    SecBuff[1].pvBuffer = pMessage;
    PBYTE pTrailer;
    pTrailer = (PBYTE) malloc (cbTrailer);
    SecBuff[2].cbBuffer = cbTrailer;
    SecBuff[2].BufferType = SECBUFFER_STREAM_TRAILER;
    SecBuff[2].pvBuffer = pTrailer;
    SecBuff[3].cbBuffer = 0;
    SecBuff[3].BufferType = SECBUFFER_EMPTY;
    SecBuff[3].pvBuffer = NULL;
    ss = EncryptMessage(
    &g_hctxt,
    ulQop,
    &BuffDesc,
    0);
    if (!SEC_SUCCESS(ss))
    LOGA ( ( __log_buf, SSPI_SERVER " EncryptMessage failed: 0x%08x\n", ss));
    return(FALSE);
    else
    LOGA ( ( __log_buf, SSPI_SERVER " The message has been encrypted. \n"));
    // Allocate a buffer to hold the encrypted data constructed from the 3 buffers.
    *pcbOutput = cbHeader + cbMessage + cbTrailer;
    * ppOutput = (PBYTE) malloc (*pcbOutput);
    memset (*ppOutput, 0, *pcbOutput);
    memcpy (*ppOutput, pHeader, cbHeader);
    memcpy (*ppOutput + cbHeader, pMessage, cbMessage);
    memcpy (*ppOutput + cbHeader + cbMessage, pTrailer, cbTrailer);
    LOGA ( ( __log_buf, SSPI_SERVER " data after encryption including trailer (%lu bytes):\n",
    *pcbOutput));
    PrintHexDump (*pcbOutput, *ppOutput);
    return TRUE;
    } // end EncryptThis
    void PrintHexDump(DWORD length, PBYTE buffer)
    DWORD i,count,index;
    CHAR rgbDigits[]="0123456789abcdef";
    CHAR rgbLine[100];
    char cbLine;
    for(index = 0; length;
    length -= count, buffer += count, index += count)
    count = (length > 16) ? 16:length;
    sprintf_s(rgbLine, 100, "%4.4x ",index);
    cbLine = 6;
    for(i=0;i<count;i++)
    rgbLine[cbLine++] = rgbDigits[buffer[i] >> 4];
    rgbLine[cbLine++] = rgbDigits[buffer[i] & 0x0f];
    if(i == 7)
    rgbLine[cbLine++] = ':';
    else
    rgbLine[cbLine++] = ' ';
    for(; i < 16; i++)
    rgbLine[cbLine++] = ' ';
    rgbLine[cbLine++] = ' ';
    rgbLine[cbLine++] = ' ';
    rgbLine[cbLine++] = ' ';
    for(i = 0; i < count; i++)
    if(buffer[i] < 32 || buffer[i] > 126)
    rgbLine[cbLine++] = '.';
    else
    rgbLine[cbLine++] = buffer[i];
    rgbLine[cbLine++] = 0;
    LOGA ( ( __log_buf, SSPI_SERVER " %s\n", rgbLine));
    } // end PrintHexDump
    BOOL SendMsg (
    SOCKET s,
    PBYTE pBuf,
    DWORD cbBuf)
    LOGA ( ( __log_buf, SSPI_SERVER " %lu bytes\n", cbBuf ));
    if (0 == cbBuf)
    return(TRUE);
    // Send the size of the message.
    if (!SendBytes (
    s,
    (PBYTE)&cbBuf,
    sizeof (cbBuf)))
    return(FALSE);
    // Send the body of the message.
    if (!SendBytes (
    s,
    pBuf,
    cbBuf))
    return(FALSE);
    return(TRUE);
    } // end SendMsg
    BOOL ReceiveMsg (
    SOCKET s,
    PBYTE pBuf,
    DWORD cbBuf,
    DWORD *pcbRead)
    DWORD cbRead;
    DWORD cbData;
    LOGA ( ( __log_buf, SSPI_SERVER " %lu bytes\n", cbBuf ));
    // Retrieve the number of bytes in the message.
    if (!ReceiveBytes (
    s,
    (PBYTE)&cbData,
    sizeof (cbData),
    &cbRead))
    LOGA ( ( __log_buf, SSPI_SERVER " ReceiveBytes failed retrieving byte count.\n", cbBuf ));
    return(FALSE);
    if (sizeof (cbData) != cbRead)
    LOGA ( ( __log_buf, SSPI_SERVER " Error: buffer size (%lu) differs from reported size (%lu)\n", sizeof(cbData), cbRead ));
    return(FALSE);
    // Read the full message.
    if (!ReceiveBytes (
    s,
    pBuf,
    cbData,
    &cbRead))
    LOGA ( ( __log_buf, SSPI_SERVER " ReceiveBytes failed.\n", cbBuf ));
    return(FALSE);
    if (cbRead != cbData)
    LOGA ( ( __log_buf, SSPI_SERVER " Error: buffer bytes (%lu) differs from reported bytes (%lu)\n", cbData, cbRead ));
    return(FALSE);
    *pcbRead = cbRead;
    return(TRUE);
    } // end ReceiveMsg
    BOOL SendBytes (
    SOCKET s,
    PBYTE pBuf,
    DWORD cbBuf)
    PBYTE pTemp = pBuf;
    int cbSent, cbRemaining = cbBuf;
    LOGA ( ( __log_buf, SSPI_SERVER " %lu bytes\n", cbBuf ));
    if (0 == cbBuf)
    return(TRUE);
    while (cbRemaining)
    cbSent = send (
    s,
    (const char *)pTemp,
    cbRemaining,
    0);
    if (SOCKET_ERROR == cbSent)
    LOGA ( ( __log_buf, SSPI_SERVER " send failed: %u\n", GetLastError ()));
    return FALSE;
    LOGA ( ( __log_buf, SSPI_SERVER " %lu bytes sent\n", cbSent ));
    pTemp += cbSent;
    cbRemaining -= cbSent;
    return TRUE;
    } // end SendBytes
    BOOL ReceiveBytes (
    SOCKET s,
    PBYTE pBuf,
    DWORD cbBuf,
    DWORD *pcbRead)
    PBYTE pTemp = pBuf;
    int cbRead, cbRemaining = cbBuf;
    LOGA ( ( __log_buf, SSPI_SERVER " %lu bytes\n", cbBuf ));
    while (cbRemaining)
    cbRead = recv (
    s,
    (char *)pTemp,
    cbRemaining,
    0);
    if (0 == cbRead)
    break;
    if (SOCKET_ERROR == cbRead)
    LOGA ( ( __log_buf, SSPI_SERVER " recv failed: %u\n", GetLastError () ) );
    return FALSE;
    cbRemaining -= cbRead;
    pTemp += cbRead;
    *pcbRead = cbBuf - cbRemaining;
    return TRUE;
    } // end ReceivesBytes
    void cleanup()
    if (g_pInBuf)
    free (g_pInBuf);
    g_pInBuf = NULL;
    if (g_pOutBuf)
    free (g_pOutBuf);
    g_pOutBuf = NULL;
    WSACleanup ();
    exit(0);
    SspiExample.h
    // SspiExample.h
    #include <schnlsp.h>
    #include <sspi.h>
    #include <windows.h>
    #include <string>
    BOOL SendMsg (SOCKET s, PBYTE pBuf, DWORD cbBuf);
    BOOL ReceiveMsg (SOCKET s, PBYTE pBuf, DWORD cbBuf, DWORD *pcbRead);
    BOOL SendBytes (SOCKET s, PBYTE pBuf, DWORD cbBuf);
    BOOL ReceiveBytes (SOCKET s, PBYTE pBuf, DWORD cbBuf, DWORD *pcbRead);
    void cleanup();
    BOOL GenClientContext (
    BYTE *pIn,
    DWORD cbIn,
    BYTE *pOut,
    DWORD *pcbOut,
    BOOL *pfDone,
    WCHAR *pCertName,
    CredHandle *hCred,
    PSecHandle phCtext
    BOOL GenServerContext (
    BYTE *pIn,
    DWORD cbIn,
    BYTE *pOut,
    DWORD *pcbOut,
    BOOL *pfDone,
    BOOL fNewCredential
    BOOL EncryptThis (
    PBYTE pMessage,
    ULONG cbMessage,
    BYTE ** ppOutput,
    LPDWORD pcbOutput,
    ULONG cbHeader,
    ULONG cbTrailer
    PBYTE DecryptThis(
    PBYTE achData,
    LPDWORD pcbMessage,
    struct _SecHandle *hCtxt
    BOOL
    SignThis (
    PBYTE pMessage,
    ULONG cbMessage,
    BYTE ** ppOutput,
    LPDWORD pcbOutput
    PBYTE VerifyThis(
    PBYTE pBuffer,
    LPDWORD pcbMessage,
    struct _SecHandle *hCtxt,
    ULONG cbMaxSignature
    void PrintHexDump(DWORD length, PBYTE buffer);
    BOOL ConnectAuthSocket (
    SOCKET *s,
    CredHandle *hCred,
    PSecHandle phCtext,
    char * pServer,
    WCHAR * pCertName
    BOOL CloseAuthSocket (SOCKET s);
    BOOL DoAuthentication (SOCKET s, WCHAR * pCertName );
    BOOL DoAuthentication (SOCKET s, std::string certThumb );
    void MyHandleError(char *s);
    #define DBG_SIZE 1024
    int OutputDebug( char buff[DBG_SIZE] )
    int retval;
    char debugstring[DBG_SIZE+32];
    retval = _snprintf_s( debugstring, DBG_SIZE+32, _TRUNCATE, " %s", buff );
    OutputDebugStringA( debugstring );
    return retval;
    int DbgBufCopy( char *buff, const char *format, ...)
    int iLen;
    va_list args;
    /// Call va_start to start the variable list
    va_start(args, format);
    /// Call _vsnprintf_s to copy debug information to the buffer
    iLen = _vsnprintf_s(buff, DBG_SIZE, _TRUNCATE, format, args);
    /// Call va_end to end the variable list
    va_end(args);
    return iLen;
    #define LOGA(_format_and_args_)\
    { char __log_buf[DBG_SIZE];\
    DbgBufCopy _format_and_args_;\
    printf("%s", __log_buf );\
    OutputDebug(__log_buf);\
    #define TEST_MSG "This is your server speaking"
    My initial attempt built an SCHANNEL_CRED structure following the documentation to set
    grbitEnabledProtocols to 0, and let SChannel select the protocol.  This worked on Windows 7, selecting TLS1.  When I ran the same exe-s on 2008 R2, the Client program failed, with InitializeSecurityContext returning SEC_E_DECRYPT_FAILURE. 
    The failure occurred on the 2nd call, using phNewContext returned on the first call.
    My next attempt set grbitEnabledProtocols to SP_PROT_TLS1_SERVER. This also worked on Win 7, but 2008R2 failed again, this time on the Server side. AcceptSecurityContext failed, returning SEC_E_ALGORITHM_MISMATCH.
    TLS is a requirement for my project, but to try getting the sample to run, I next set grbitEnabledProtocols to SP_PROT_SSL2_SERVER.  This did work for 2008R2, selecting SSL2, but now the Server failed on Win7 with AcceptSecurityContext returning
    SEC_E_ALGORITHM_MISMATCH.
    My final try was to set grbitEnabledProtocols to SP_PROT_TLS1_SERVER | SP_PROT_SSL2_SERVER, but that failed identically to the first case, with the Client on 2008R2 returning SEC_E_DECRYPT_FAILURE.
    So my question is - What is required to get SChannel to select TLS regardless of the Windows version on which the programs are running?

    Thank you for the reference.  That did provide the information I needed to get TLS working.   However, the documentation is not accurate with regard to setting the registry keys and values.
    The tables all show DisabledByDefault as a subkey under the protocol.  They also describe a DWORD value, Enabled, as the mechanism to enable/disable a protocol.
    What I found is DisabledByDefault is a DWORD value under Client/Server and it appears to be the determining factor to whether a protocol is enabled/disabled.
    The only way I was able to get TLS 1.1 working is with the following path present:
    HKLM SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client
    Under Client, I must have DisabledByDefault set to 0.  With that, the Enabled value does not need to be present.
    This held true for any level of TLS.
    I also found the setting of grbitEnabledProtocols in the SCHANNEL_CRED structure to be misleading.  From the description at
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa379810(v=vs.85).aspx, I thought my Server program could set this field to 0, and SChannel would select the protocol as directed by the registry.  What I found is that the structure flag must
    agree with the registry setting for TLS to work.  That is with the resgistry key above for TLS 1.1, I must set grbitEnabledProtocols to SP_PROT_TLS1_1.
    Can you confirm the relationship between the SCHANNEL_CRED contents and registry state?

  • Installing Oracle 10.2.0 on Windows Server 2008 64bit

    Dear all(s)
    Recently i am running production database 10.2.0 on windows server 2003 32 bit. there is some memory limits and i cannot set SGA,PGA > 2 GB.
    I want to mode production database 10.2.0 on windows server 2003 64 bit, please guide me in following topics:
    1. What steps i have to take for moving database from 32bit to 64bit
    2. After moving database on Microsoft windows server 2003 64bit, i can set SGA,PGA more than 4 to 6 GB
    3. How much SGA,PGA i can configure
    4. Dataguard also configured on another server for production database.
    5. I have to again setup dataguard on 64bit.
    6. What others seniors which i have to meet.
    Waiting for response
    Naeem Sheeraz
    Faisababad, Pakistan

    Naeem,
    +1. What steps i have to take for moving database from 32bit to 64bit+
    You can make use of conventional export/import, investigate using data pump, transportable tablespaces, and RMAN backup/restore. Simplest will busing e conventional export/import
    +2. After moving database on Microsoft windows server 2003 64bit, i can set SGA,PGA more than 4 to 6 GB+
    I think you can go beyond 6gb may be upto 20gb (if system can hold that much :))
    +3. How much SGA,PGA i can configure+
    Depending upon your requirement, what kind of work you are doing database, large queries, lots of DML activities, transactions., how many users simultaneously (at the same time) will access your database?
    +4. Dataguard also configured on another server for production database.+
    +5. I have to again setup dataguard on 64bit.+
    YOu should follow the same setup as your primary setup for same kind of services and performance
    6. What others seniors which i have to meet.
    I didn't understand what do you mean? Do you mean requriement?
    Regards

  • Oracle Database 11g-R2 with Windows Server 2008

    Hi to All Respected Gurus!
    Recently I have downloaded Oracle Database 11g-R2.
    Will it work with Windows Server 2008-R2?
    Please guid eme.
    Thanks in Advance.
    Muhammad Uzair
    Oracle Application Developer
    Oracle APEX Developer
    Pakistan
    +92 (333) 7058754

    uzairmalik wrote:
    Hi to All Respected Gurus!
    Recently I have downloaded Oracle Database 11g-R2.
    Will it work with Windows Server 2008-R2?
    Please guid eme.
    Did you look in the installation guide for the software requirement for 11.2? You could had easily found the answer from there by yourself.
    http://docs.oracle.com/cd/E11882_01/install.112/e24186/reqs.htm#CHDHGGFE
    From the above link,
    >
    Requirement     Value
    Operating System
    Oracle Database for 32-bit Windows is supported on the following operating systems:
    Windows Server 2003 - all editions
    Windows Server 2003 R2 - all editions
    Windows XP Professional
    Windows Vista - Business, Enterprise, and Ultimate editions
    Windows Server 2008 - Standard, Enterprise, Datacenter, Web, and Foundation editions. The Server Core option is not supported.
    Note: Check My Oracle Support (formerly OracleMetaLink) for more information about Hyper-V support.
    Windows 7 - Professional, Enterprise, and Ultimate editions
    Windows Multilingual User Interface Pack is supported.
    >
    Aman....

  • Oracle Database XE with Microsoft Windows Server 2008 (32-bit)

    I would like to find out if Oracle Database XE works with Microsoft Windows Server 2008 (32-bit)?
    If not, is there any other Oracle Open Source Database version can work with Microsoft Windows Server 2008 (32-bit)?
    Any help would be greatly appreciated!

    I am installing W2k8 R2 Domain Controller with Oracle Express 10g.
    This is the tip to make it work.
    Go to the installer OracleXE.exe -> Right click + Select Properties + Compatibility + Run this program in Compatibility Mode fot + Windows 2003 Sp1
    Then Select Run this Program as administrator.
    After this run the OracleXe.exe and it will install properly.
    Remember to double check that everything works fine.

  • Installing Oracle 11gR2 Standard Edition on WINDOWS Server 2008R2 with ASM

    Hi,
    I want to setup Oracle 11g DB (11.2.0.2) Standard Edition on Windows Server 2008R2 x64 bit with ASM Instance. I would appreciate if you could suggest me with the following little but important questions.
    The following link from Oracle doesnt have 11.2.0.2 db version for windows x64 bit. Do a patch (which I think is a complete installation) is needed to install after installing 11.2.0.1? or I can directly install 11.2.0.2?
    http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html
    Secondly, I have no such experience regarding installing and setting up ASM Instance on windows. How many disks or etc is needed for ASM (as ASM disks). One of the admin guy said, he has 6 disks (2 for OS and 6 you can use for Oracle or ASM so so). Could you please suggest, how should I divide the disk partitions of what should I say no idea :(
    Also, do ASM instance (diskgroups,disks) should be setup before creating DB (through dbca?)
    I was thinking like:
    - Installing Oracle software
    - Creating ASM disks,diskgroups,instance,etc
    - Creating DB (using dbca?), isnt' it?
    Bundle of thanks in advance.
    Best Regards

    K-Saf wrote:
    Hi,
    I want to setup Oracle 11g DB (11.2.0.2) Standard Edition on Windows Server 2008R2 x64 bit with ASM Instance. I would appreciate if you could suggest me with the following little but important questions.
    The following link from Oracle doesnt have 11.2.0.2 db version for windows x64 bit. Do a patch (which I think is a complete installation) is needed to install after installing 11.2.0.1? or I can directly install 11.2.0.2?
    http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html
    Secondly, I have no such experience regarding installing and setting up ASM Instance on windows. How many disks or etc is needed for ASM (as ASM disks). One of the admin guy said, he has 6 disks (2 for OS and 6 you can use for Oracle or ASM so so). Could you please suggest, how should I divide the disk partitions of what should I say no idea :(
    Also, do ASM instance (diskgroups,disks) should be setup before creating DB (through dbca?)
    I was thinking like:
    - Installing Oracle software
    - Creating ASM disks,diskgroups,instance,etc
    - Creating DB (using dbca?), isnt' it?
    Bundle of thanks in advance.
    Best Regards-You should create ASM
    -After this you could be able to create DB

  • Failed to install windows server 2012 in virtual machine hosted in window 8.1

    I installed Hyper-V in windows 8.1, then when I tried to install windows server 2012 R2 or windows server 2008 R2 in virtual machine, I got the following error:
    the following is my virtual machine setting:
    is there anyone an help to resolve it? thank you very much.

    Hi,
    Good to hear that you have solved this issue. Thanks for sharing as it would be helpful to anyone who encounters similar issues.
    Best regards,
    Susie

Maybe you are looking for

  • How to create secure EJB web service in Oc4J using JDeveloper?

    We are going to develop a EJB web service running in OC4J using JDeveloper 10.1.3.3. By using the JDeveloper feature, we can simply create the web service by using the "Web Service Endpoint Interface" in the session bean. However, unlike the web serv

  • SQL Error:  DSNT408I SQLCODE = -913

    BI_PROCESS_ODSACTIVAT failed with log 03/30/2008  4:57:45     SQL Error:  DSNT408I SQLCODE = -913, ERROR:  UNSUCCESSFUL EXE I     DBMAN     257 short dump is Information on where terminated                                                             

  • ORA-02095: specified initialization parameter cannot be modified

    Oracle : 10.2.0.4 I am getiing below error while setting this parameter in one of teh RAC instance. ORA-02095: specified initialization parameter cannot be modified Is there any solution for that ? Thx.

  • Links in navbar work in iWeb, not on site itself

    Hi Folks, I got rid of the iWeb default navbar and made my own. I am linking to other pages within my site. They are set up correctly in the inspector, and in fact, when I click on the links in iWeb, they take me to the correct place. However, when I

  • "do not print" option

    Is there now a "do not print" option in numbers '09? I use numbers to print form. I 've used MS Excel until now, because the "do not print cell" option did not exist in numbers '08. Does it now?