我尝试使用"crypto/x509"软件包生成CSR,但没有找到在其Subject中添加"emailAddress"字段的方法.
根据文档,CertificateRequest结构有一个"EmailAddresses [] string"字段,但它被序列化为SAN扩展.这是我使用的测试代码:http: //play.golang.org/p/OtObaTyuTM
我还使用"openssl req"程序创建了一个CSR并比较了结果:
% openssl req -in openssl.csr -noout -text
Certificate Request:
Data:
Version: 0 (0x0)
Subject: C=AU, ST=Some-State, L=MyCity, O=Company Ltd, OU=IT, CN=domain.com/emailAddress=test@email.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (512 bit)
Modulus:
00:a3:05:e3:37:63:f9:8b:d0:37:46:2d:a8:d9:26:
4e:be:83:1d:b9:30:88:2b:80:4b:53:cc:7c:01:86:
b0:9b:1d:3b:0a:05:c4:56:47:4e:5d:90:f9:5a:29:
8b:9a:7f:fa:4b:5e:e4:5d:dd:c6:8b:87:33:c4:b4:
fa:6b:b4:67:bd
Exponent: 65537 (0x10001)
Attributes:
a0:00
Signature Algorithm: sha1WithRSAEncryption
0b:24:6e:0a:f9:bf:23:d7:41:5f:96:da:78:d1:99:18:fb:d6:
71:7e:79:f0:02:e9:8a:50:a9:00:32:df:26:14:2f:f4:3e:c4:
22:c9:5c:4e:79:c1:c2:22:1b:2a:da:79:6f:51:ba:8a:12:63:
27:02:4a:b3:22:97:59:f7:6e:d6
===============================================================
% openssl req -in golang.csr -noout -text
Certificate Request:
Data:
Version: 0 (0x0)
Subject: C=AU, O=Company Ltd, OU=IT, …Run Code Online (Sandbox Code Playgroud) 我的后端服务响应XML,我默认返回它.
如果客户端给我一个adds参数(比如:&outout_format = json),我需要在"outSequence"中将响应转换为JSON.
例如:
<result>
<foo>bar</foo>
<foo2>bar2</foo2>
<nested>
<node>value</node>
</nested>
</result>
Run Code Online (Sandbox Code Playgroud)
应该作为回应
{
"foo": "bar",
"foo2": "bar2",
"nested":{
"node":"value"
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个测试代理服务(我只是在这里使用inSequence来显示问题):
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JSONtest"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="TEST_WAITING_FOR"
value="json"
scope="default"
type="STRING"/>
<header name="To" action="remove"/>
<property name="RESPONSE" value="true"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<payloadFactory media-type="xml">
<format>
<response xmlns="">
<result>success</result>
<code>123</code>
</response>
</format>
<args/>
</payloadFactory>
<switch source="get-property('TEST_WAITING_FOR')">
<case regex="json">
<property name="messageType"
value="application/json"
scope="axis2"
type="STRING"/>
</case>
<default>
<property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
</default>
</switch>
<send/> …Run Code Online (Sandbox Code Playgroud)