首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WinRM(WsMan)和NTLM认证

WinRM(WsMan)和NTLM认证
EN

Stack Overflow用户
提问于 2017-08-10 21:21:27
回答 2查看 1.7K关注 0票数 0

在WsMan连接期间,我试图使用NTLM身份验证。但是WinRm不直接支持NTLM方案的问题。以下是响应头:

代码语言:javascript
复制
21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 401 [\r][\n]"
21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: Microsoft-HTTPAPI/2.0[\r][\n]"
21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "WWW-Authenticate: Negotiate[\r][\n]"
21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "WWW-Authenticate: Kerberos[\r][\n]"
21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "WWW-Authenticate: CredSSP[\r][\n]"
21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Thu, 10 Aug 2017 18:57:33 GMT[\r][\n]"
21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: close[\r][\n]"
21:57:33.557 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 0[\r][\n]"

官方文档https://learn.microsoft.com/en-us/powershell/module/Microsoft.WsMan.Management/Get-WSManInstance?view=powershell-5.1中没有提到NTLM方案

但上面写着

谈判。协商是一种挑战响应方案,它与服务器或代理协商以确定用于身份验证的方案。例如,该参数值允许协商以确定是否使用Kerberos协议或NTLM。

我正在尝试使用SPNEGO模式

代码语言:javascript
复制
RegistryBuilder<AuthSchemeProvider> builder = RegistryBuilder.<AuthSchemeProvider>create().register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory());

但是最后,它失败了https://pastebin.com/gGNEHGpx,所以看起来NTLM是SPNEGO的子机制,但是如何在Apache中正确地使用它呢?

EN

回答 2

Stack Overflow用户

发布于 2017-08-11 14:02:57

Stack Overflow用户

发布于 2017-08-11 12:11:53

我找到了一个SpNegoNTLMSchemeFactory,它与WinRm https://gist.github.com/moberwasserlechner/4690931正确地工作。

JCIFSEngine.java == apache NTLMEngineImpl.java SpNegoNTLMSchemeFactory.java == apache NTLMSchemeFactory.java

SpNegoNTLMScheme.java != apache NTLMScheme.java,但这里唯一的区别是

代码语言:javascript
复制
  @Override
  public String getSchemeName() {
    return AuthSchemes.SPNEGO; //<- apache class return NTLM here
  }


  @Override
  public Header authenticate(final Credentials credentials, final HttpRequest request) throws AuthenticationException {
    ...
    buffer.append(": ");
    buffer.append(getSchemeName().toUpperCase());  //<- apache class return NTLM here
    buffer.append(" ");
    buffer.append(response);
    return new BufferedHeader(buffer);
  }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45623622

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档