简体   繁体   English

GAE上的Web服务的双向SSL(java)

[英]2-way SSL for web services on GAE (java)

We need to implement two-way SSL on Google App Engine, where we send out web service requests using JAX-WS to a server requring 2-way SSL authentication. 我们需要在Google App Engine上实施双向SSL,我们使用JAX-WS向需要双向SSL身份验证的服务器发送Web服务请求。

How can we set up 2-way SSL for our outgoing web service requests? 我们如何为传出的Web服务请求设置双向SSL?

We know that javax.net.ssl* is forbidden in the App Engine environment. 我们知道app Engine环境中禁止使用javax.net.ssl*

Here's an example of our code: 这是我们代码的一个例子:

@WebService(name="ListenerSoap", targetNamespace = "http://example.com/Listener.Wsdl")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface ListenerSoap {

    @WebMethod(operationName = "Ping", action="http://example.com/Listener.Wsdl#Ping")
    public void ping();
}

@WebServiceClient(name="Listener", targetNamespace="http://example.com/Listener.Wsdl", wsdlLocation = "https://example.com/Listener.asmx?WSDL")
public class Listener extends Service
{
  public ListenerSoap getListenerSoap() {
   return super.getPort(new QName("http://example.com/Listener.Wsdl", 
                       "ListenerSoap"), ListenerSoap.class);
  }
}

And an example of above code in use: 以上代码的一个例子:

ListenerSoap soap = new Listener().getListenerSoap();
soap.ping();

I figure we can store the keystores or any certs needed in the DataStore as binary objects (though how to upload them is still a lil' vague to me). 我想我们可以将DataStore中所需的密钥库或任何证书存储为二进制对象(尽管如何上传它们对我来说仍然是模糊的)。

How can we go about setting the necessary values needed for this web service to authenticate using 2-way SSL? 我们如何设置此Web服务使用双向SSL进行身份验证所需的必要值?

Thanks for any help 谢谢你的帮助

Update: 更新:

Through research I've seen this is how it can be done on a traditional server (one with filesystem access): 通过研究我已经看到这是如何在传统服务器上进行的(一个具有文件系统访问权限):

ListenerSoap soap = new Listener().getListenerSoap();
((BindingProvider) soap).getRequestContext().put("javax.net.ssl.keyStore", "client_cert.p12"

However, in this approach, client_cert.p12 is expected to be on the filesystem. 但是,在这种方法中, client_cert.p12应该在文件系统上。

Additionally, SSLSocketFactory , SSLContext , KeyManager , and KeyManagerFactory all aren't allowed on GAE. 此外,GAE上不允许使用SSLSocketFactorySSLContextKeyManagerKeyManagerFactory

Update: 更新:

As of GAE SDK version 1.7.7. 截至GAE SDK 1.7.7版。 this should now be possible: 这应该是可能的:

Similarly, Java developers can now use the javax.net.ssl package to make outbound SSL connections.

GAE 1.7.7 SDK Release Notes GAE 1.7.7 SDK发行说明

From my restricted knowledge about SSL authorization, it seems you may be missing something of vital importance here; 根据我对SSL授权的限制知识,您可能会遗漏一些至关重要的内容; the certificates. 证书。 Two-way SSL requires the client and server certificates to be in your keystore, which can be either a self-signed certificate( a pkcs12 or pem file, which you can easily generate with a few commands through shell) or a proprietary certificate issued by an authorized company like Thawte or Verisign. 双向SSL要求客户端和服务器证书位于密钥库中,密钥库可以是自签名证书(pkcs12或pem文件,您可以通过shell轻松生成一些命令)或由Thawte或Verisign等授权公司。 Although I am not sure if that is the problem you are facing, but its good to check it out. 虽然我不确定你是否面临这个问题,但是很好看。 (Also, I am a newbie so please don't downvote my answer, just trying to suggest possible options.) (另外,我是新手,所以请不要低估我的答案,只是尝试建议可能的选项。)

ListenerSoap soap = new Listener().getListenerSoap();

Hope it improves 希望它有所改善

Thanks 谢谢

I know you might not want to hear this, but using SSL is expensive and problematic for two way communication. 我知道你可能不想听到这个,但使用SSL是昂贵的,并且对双向通信有问题。 Depending on how much control you have over the server/client ends, I prefer a simple bi-directional pipe like web sockets and a data packet protocol that can simply implement AES. 根据您对服务器/客户端的控制程度,我更喜欢简单的双向管道,如Web套接字和可简单实现AES的数据包协议。 It really depends on the problem you are trying to solve. 这实际上取决于您要解决的问题。

It sounds like there is confusion over simple connection over SSL ( https://... ) and what is known as "mutual authentication" or "public key infrastructure (PKI)". 听起来像是通过SSL( https://... )进行简单连接以及所谓的“相互身份验证”或“公钥基础结构(PKI)”存在混淆。 You can actually do both or one independent of another. 你实际上可以做两个或一个独立于另一个。 With the latter (what I think the original question is referring to), when you make a request to the server, the server will respond to you asking for a certificate which you must present to authenticate yourself. 对于后者(我认为原始问题所指的是),当您向服务器发出请求时,服务器将响应您要求提供证书,您必须出示该证书以进行身份​​验证。

To answer the specific question above (loading a keystore from binary data), I don't think that is really possible, since it's the Java runtime that picks up on your keystore. 为了回答上面的具体问题 (从二进制数据加载密钥库),我认为这不可能,因为它是在运行密钥库的Java运行时。 The only think you could do is load the bits from your datastore and temporarily write it to disk. 您可以做的唯一想法是从数据存储区加载位并暂时将其写入磁盘。 Optionally delete it when the application exists. (可选)在应用程序存在时删除它。 This I have done before and works fairly well. 这是我以前做过的,并且运作得相当好。 If you do this, I'd recommend using a location likely to be writable (such as System.getProperty("java.io.tmpdir")); 如果你这样做,我建议使用一个可写的位置(例如System.getProperty("java.io.tmpdir")); ), then after writing the file to disk, set the JVM properties (eg System.getProperties().put( "javax.net.ssl.keyStore","..."); ) ),然后在将文件写入磁盘后,设置JVM属性(例如System.getProperties().put( "javax.net.ssl.keyStore","...");

You will need App Engine's Socket API for this. 您将需要App Engine的Socket API。 This API is in trusted tester mode, so it's not available for everyone. 此API处于受信任的测试人员模式,因此并非适用于所有人。

You can ask for an access gere : https://docs.google.com/spreadsheet/viewform?formkey=dF9QR3pnQ2pNa0dqalViSTZoenVkcHc6MQ#gid=0 您可以要求访问gere: https ://docs.google.com/spreadsheet/viewform formkey = dF9QR3pnQ2pNa0dqalViSTZoenVkcHc6MQ #gid = 0

2-way SSL (from app hosted in GAE to outside world) is not supported as far as I know. 据我所知,不支持双向SSL(从GAE托管的应用程序到外部世界)。 I tried a sample app few months ago and was frustrated to find GAE does n't even support this basic feature.. and the documentations are n't clear either. 几个月前我尝试了一个示例应用程序,并且很惊讶地发现GAE甚至不支持这个基本功能..而且文档也不清楚。 You won't be able to present client cert when you contact a web-service.. there is no place to store it, the keystore cannot be accessed. 当您联系网络服务时,您将无法提供客户端证书..没有地方存储它,无法访问密钥库。

For what i know about two way SSL, you will have no link with Java EE code: two way SSL is a transport layer security: when your client application will try to create a secured HTTP connection (HTTPS) with the serve, the server will ask for a certificate and will approve or not this certificate. 对于我对双向SSL的了解,您将无法使用Java EE代码:双向SSL是传输层安全性:当您的客户端应用程序尝试使用该服务创建安全HTTP连接(HTTPS)时,服务器将索取证书并批准或不批准此证书。 If the client certificate is approved, then a secured connection will be established on parties and they are allow to exchange some messages through this tunnel. 如果客户端证书被批准,则将在各方建立安全连接,并允许它们通过此隧道交换一些消息。 But this process is done on the transport layer. 但是这个过程是在传输层完成的。 Your code (on application layer) will never be informed of this process. 您的代码(在应用程序层上)永远不会被告知此过程。 In order to established two way SSL, the setup is done on the application server setup for the SSL port. 为了建立双向SSL,在SSL端口的应用程序服务器设置上完成设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM