@@ -813,6 +813,8 @@ gss_accept_sec_context(_Out_ OM_uint32 * minor_status, _Inout_opt_ gss_ctx_id_t
813813{
814814 OM_uint32 ret = GSS_S_FAILURE ;
815815 gss_ctx_id_t p_ctx_h = NULL ;
816+ CredHandle * p_acceptor_cred_handle = NULL ;
817+ SECURITY_STATUS status ;
816818
817819 * src_name = NULL ;
818820
@@ -822,6 +824,24 @@ gss_accept_sec_context(_Out_ OM_uint32 * minor_status, _Inout_opt_ gss_ctx_id_t
822824 if (ssh_gss_sspi_init (minor_status ) == 0 )
823825 goto done ;
824826
827+ if (acceptor_cred_handle == GSS_C_NO_CREDENTIAL ) {
828+ static CredHandle default_cred_handle = { 0 , 0 };
829+ TimeStamp cred_expiry ;
830+
831+ if (default_cred_handle .dwLower == 0 &&
832+ default_cred_handle .dwUpper == 0 ) {
833+ status = SecFunctions -> AcquireCredentialsHandleW (NULL ,
834+ MICROSOFT_KERBEROS_NAME_W , SECPKG_CRED_INBOUND ,
835+ NULL , NULL , NULL , NULL , & default_cred_handle ,
836+ & cred_expiry );
837+ if (status != SEC_E_OK )
838+ goto done ;
839+ }
840+ p_acceptor_cred_handle = & default_cred_handle ;
841+ } else {
842+ p_acceptor_cred_handle = & acceptor_cred_handle -> credHandle ;
843+ }
844+
825845 /* setup input buffer */
826846 SecBuffer input_buffer_token = { (unsigned long ) input_token_buffer -> length ,
827847 SECBUFFER_TOKEN | SECBUFFER_READONLY , input_token_buffer -> value };
@@ -842,7 +862,7 @@ gss_accept_sec_context(_Out_ OM_uint32 * minor_status, _Inout_opt_ gss_ctx_id_t
842862 ASC_REQ_DELEGATE | ASC_REQ_SEQUENCE_DETECT | ASC_REQ_ALLOCATE_MEMORY ;
843863
844864 /* call sspi accept security context function */
845- const SECURITY_STATUS status = SecFunctions -> AcceptSecurityContext (& acceptor_cred_handle -> credHandle ,
865+ status = SecFunctions -> AcceptSecurityContext (p_acceptor_cred_handle ,
846866 (* context_handle == GSS_C_NO_CONTEXT ) ? NULL : * context_handle , & input_buffer ,
847867 sspi_req_flags , SECURITY_NATIVE_DREP ,
848868 (* context_handle == GSS_C_NO_CONTEXT ) ? & sspi_context_handle : * context_handle ,
0 commit comments