我正在为天气使用 Dialogflow 履行网络钩子。
Dialogflow 显示“启用“Google 助理”集成后,您只能在履行 url 中使用 https://”
所以,我尝试了 https url 的自签名证书。但我无法得到 webhook 响应。
我不能对 webhook url 使用自签名证书?
感谢您的任何帮助!
编辑 我现在正在移动,并且在我的 iPhone 上的 Stack Exchange 应用程序上只有 SO,所以下面的代码中的引号有一些奇怪的格式 - 抱歉!我在真实的代码中有真实的:)
两天来,我一直试图通过其他一些关于 SO 的问题来解决这个问题,但是这里...
只是试图用来file_get_contents()捕获位于同一服务器和同一域上的另一个文件的网页,并将其包含在内。我正在使用带有自签名证书的 MAMP 进行生产(以便我可以让服务器强制使用 SSL 等),所以我的 Mac 本地也有该证书为“始终受信任”,因为它显然是自签名的。
所以现在我有一个问题,我想要一个页面来捕获另一个页面的内容..我最初尝试使用 cURL 并且它失败了没有给我任何异常,并且没有使用信息curl_error()所以我切换到file_get_contents()我得到异常的地方SSL operation failed with code 1.. .ssl3_get_server_certificate:certificate verify failed
我认为这是 OpenSSL 不信任自签名的问题(但我认为它使用了底层操作系统的可信 CA?)并且我无法使用以下流上下文使其工作:
stream_context_create([
"ssl" => [
"allow_self_signed" => true
]
]);
Run Code Online (Sandbox Code Playgroud)
如果我将verify_peerand设置verify_peer_name为 false,则会发出请求,但不会发送 HTTPS cookie,这会破坏整个过程。
我已经尝试将证书的实际文本添加到cacert.pemMAMP 中 OpenSSL 目录下的文件中,并在文件中的openssl.cafile选项中设置该文件,php.ini如另一个答案中所述,但可惜没有运气......
有任何想法吗?您的帮助将不胜感激!谢谢!??
编辑 2 所以我再次尝试使用 cURL,这次让 cURL 给我一些详细的文件输出,这就是它给我的(注意底部第三行):
* Trying …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个在自定义本地域上使用 API 的项目(本地 DNS 服务器将自定义 tld 重定向到本地主机)。在我的计算机上,我有一个带有 mkcert 证书的 nginx 反向代理,该证书已加载并在 Firefox、Chrome 和 Curl 中运行(证书已安装并运行)。我正在运行 archlinux,如果这相关的话。
当我尝试使用电子应用程序时,我收到消息“证书链中的自签名证书”。
有办法解决这个问题吗?我已经尝试使用 nodejs 的 env var 禁用 ssl 验证并使用syswidecas npm 包,但没有成功。
I seem not to be able to grasp they way SSL is working... or ar least I'm not able to interpret the ssl debugging output of java, so here's what I (plan to) do: Client and Server generate their own keypair and self-signed certificate. (I only need to ensure the identity upon reconnection.) For testing I use the same key- and truststure (with only one key and certificate) on both, the server and the client. Something goes wrong during the …
我有一个包含以下代码的servlet:
System.setProperty("javax.net.ssl.keyStore", getServletContext().getRealPath("keystore.jks"));
System.setProperty("javax.net.ssl.keyStorePassword", "123456");
System.setProperty("javax.net.ssl.trustStore",getServletContext().getRealPath("keystore.jks"));
System.setProperty("javax.net.ssl.trustStorePassword","123456");
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket("127.0.0.1", 606);
Run Code Online (Sandbox Code Playgroud)
使用此代码,我可以使用SSL(我的情况是强制性的).稍后在同一个servlet中,我需要使用JavaMail发送电子邮件.当我尝试在不使用其他代码中的证书的情况下发送此电子邮件时,它工作正常,但是当我尝试使用它时,会返回以下消息:使用端口465 - >
DEBUG: setDebug: JavaMail version 1.4.7
DEBUG: setDebug: JavaMail version 1.4.7
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL false
Run Code Online (Sandbox Code Playgroud)
Aaand被困在这个= p.
使用端口587 - >
DEBUG: setDebug: JavaMail version 1.4.7
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG …Run Code Online (Sandbox Code Playgroud) 我在 Windows Server Enterprise 2008 上使用 IIS 7 来生成自签名证书以与 IIS 一起使用(基本上是一键式按钮)。
但是,即使我将此证书导出并将其添加到 Windows 客户端的 curl-ca-bundle.crt,它和 openssl.exe 都不会正确验证证书:
openssl s_client -CAfile curl-ca-bundle.crt -showcerts -connect myserver.ad.pri:443
CONNECTED(00000003)
depth=0 /CN=myserver.ad.pri
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 /CN=myserver.ad.pri
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
0 s:/CN=myserver.ad.pri
i:/CN=myserver.ad.pri
-----BEGIN CERTIFICATE-----
MIIDADCCAeigAwIBAgIQTi9gdBLdo6pJ1h4Zljr/wzANBgkqhkiG9w0BAQUFADAp
....
-----END CERTIFICATE-----
---
Server certificate
subject=/CN=myserver.ad.pri
issuer=/CN=myserver.ad.pri
---
No client certificate CA names sent
---
SSL handshake has read 924 bytes and written …Run Code Online (Sandbox Code Playgroud) 我正在使用下一个命令来创建自签名数字签名证书:
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout myCert.pem -out homeMadeCrt/myCert_20140209_230846.pem -subj "/C=IL/ST=Oregon/L=Portland/O=companyName/CN=CommonName/GN=GivenName/SN=SureName/emailAddress=email@addresss.com/serialNumber=123456"
openssl pkcs12 -export -in myCert.pem -out myCert.p12 -password pass:foobar
openssl pkcs12 -in myCert.p12 -out myCert.crt -password pass:foobar
一切都很好,唯一的问题是我需要发行人的详细信息与主题不同,但在这种方法中它们是相同的。
你知道我可以控制发行人的详细信息吗?
我必须通过SSL双重身份验证连接到服务器.我已将自己的私钥加证书添加到keystore.jks,并将服务器的自签名证书添加到truststore.jks,这两个文件都复制到/ usr/share/tomcat7.我的代码使用的套接字工厂由以下提供者提供:
@Singleton
public static class SecureSSLSocketFactoryProvider implements Provider<SSLSocketFactory> {
private SSLSocketFactory sslSocketFactory;
public SecureSSLSocketFactoryProvider() throws RuntimeException {
try {
final KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
final InputStream trustStoreFile = new FileInputStream("/usr/share/tomcat7/truststore.jks");
trustStore.load(trustStoreFile, "changeit".toCharArray());
final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(trustStore);
final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
final InputStream keyStoreFile = new FileInputStream("/usr/share/tomcat7/keystore.jks");
keyStore.load(keyStoreFile, "changeit".toCharArray());
final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, "changeit".toCharArray());
final SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
this.sslSocketFactory = sslContext.getSocketFactory();
} catch (final KeyStoreException e) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Python从内部服务器下载一些数据.由于它是内部的,因此它使用自签名证书.(我们不想向Verisign支付那些永远不会出现的服务器.)Python 2.6版本的代码运行良好.
response = urllib2.urlopen(URL)
data = csv.reader(response)
Run Code Online (Sandbox Code Playgroud)
我现在正在尝试更新到Python 3.4(长话,不要问.)但是,使用Python 3的urllib失败:
response = urllib.request.urlopen(URL)
Run Code Online (Sandbox Code Playgroud)
它会抛出CERTIFICATE_VERIFY_FAILED错误.
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)>
Run Code Online (Sandbox Code Playgroud)
在网上阅读时,显然Python 2.6 urllib2并不打算验证证书.某些版本的urllib允许将"verify = False"传递给方法签名,但这似乎不适用于Python 3.4.
有谁知道我怎么能解决这个问题?由于公司安全准则,我想避免使用Requests包.
我有两台服务器需要使用HTTPS互相交谈.
在这种情况下,我们将它们称为"服务器"和"客户端",其中"客户端正在对"服务器"进行https调用.
在生产中,服务器将具有有效的CA证书,但在测试时,我们将使用自签名证书.
据我所知,这是我们必须做的:
这一切都已完成,但在拨打电话时我收到此错误:
Caused by: javax.net.ssl.SSLPeerUnverifiedException: Host name 'docker-abc-123' does not match the certificate subject provided by the peer (CN=docker-abc-123, OU=unit, O=org, L=city, ST=area, C=xx)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:465) [httpclient-4.5.jar:4.5]
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:395) [httpclient-4.5.jar:4.5]
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) [httpclient-4.5.jar:4.5]
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:91) [spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) [spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) [spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:568) [spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
... 10 …Run Code Online (Sandbox Code Playgroud) self-signed ×10
ssl ×6
java ×3
openssl ×3
certificate ×2
node.js ×2
curl ×1
docker ×1
electron ×1
httpclient ×1
https ×1
iis ×1
jakarta-mail ×1
keystore ×1
mamp ×1
netty ×1
php ×1
python ×1
python-3.x ×1
servlets ×1
truststore ×1
urllib ×1
webhooks ×1