我已经在 WCF 上挣扎了一段时间,但我似乎无法弄清楚。我有一个启用了 SSL 的自托管 WCF 服务(使用来自自签名根 CA 的签名证书),到目前为止一切顺利。该服务用于企业对企业的通信,因此证书似乎是最好的解决方案。
(我目前正在使用 WS 绑定,但这仅用于开发目的,因为所有绑定方法都支持(据我所知)客户端证书的传输级安全性。)
该服务的一些相关配置位:
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<!-- snip -->
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="CurrentUser" />
</clientCertificate>
</serviceCredentials>
Run Code Online (Sandbox Code Playgroud)
当我让客户端使用位于运行 WCF 服务的用户的“受信任的人”存储中的自签名证书时,它会失败。当我使用由我自己的根 CA 签名的证书时,即使它不在“受信任的人”存储中,它也可以工作。
我期望我能够使用自签名证书,将它们存储在“受信任的人”存储中,一切都会正常进行。但似乎正在进行一些额外的验证,我是否缺少某些东西?有没有更好的办法?
我正在尝试打开非安全(端口 143)IMAP 连接(我使用的是 PHP):
imap_open('{localhost:143/imap}INBOX', USERNAME, PASS);
Run Code Online (Sandbox Code Playgroud)
我得到下一个错误: Certificate failure for localhost: self signed certificate ...
好的。我试过使用/novalidate-cert邮箱参数。然后我得到另一个错误:Can not authenticate to IMAP server.
我还尝试结合所有可能的非安全连接参数,如/notls,/norsh和/secure。但我总是出错。
这是我正在使用的 Dovecot 配置:
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=LOGIN] Dovecot ready.
该证书实际上是自签名的,并使用 openssl 生成。
问题是:
我有一个使用自签名证书的自托管 WebAPI Web 服务。我能够使用以下 URL 成功地与其他应用程序的 Web 服务控制器操作进行通信:
https://localhost:5150/...
Run Code Online (Sandbox Code Playgroud)
请注意,我已成功将自签名证书绑定到端口 5150,并为我的应用程序的所有 IP 保留该端口,这都是通过使用适当的netsh命令实现的。
我正在尝试将 SignalR 集线器集成到此 Web 服务中。我在启动代码中使用以下内容配置具有 CORS 支持的集线器:
// Configure the SignalR hub that will talk to the browser
appBuilder.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
HubConfiguration hubConfig = new HubConfiguration();
hubConfig.EnableDetailedErrors = true;
hubConfig.EnableJavaScriptProxies = false;
map.RunSignalR(hubConfig);
});
Run Code Online (Sandbox Code Playgroud)
我正在启动我的 HTTP 侦听器,它也用于 Web API:
_webApp = WebApp.Start<Startup>(baseUrl);
Run Code Online (Sandbox Code Playgroud)
其中 baseUrl 是
https://+:5150/.
Run Code Online (Sandbox Code Playgroud)
我的 SignalR 初始化代码在我的 Angular 控制器中是:
var initialize = function () {
//Getting the connection object
connection = …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Node.js 中使用 HTTP 自签名证书。
我已经使用我编写的以下脚本生成了证书:
生成文件
#!/bin/bash
read -p "FQDN: " FQDN
# for easy testing
rm ROOT.*
rm SERVER.*
openssl genrsa 4096 > ROOT.key
openssl req -x509 -nodes -sha256 -new -key ROOT.key -days 365 -subj "/C=AU/CN=example" > ROOT.crt
openssl req -newkey rsa:4096 -nodes -sha256 -keyout SERVER.key -subj "/C=AU/CN=${FQDN}" > SERVER.csr
openssl x509 -days 365 -req -in SERVER.csr -CA ROOT.crt -CAkey ROOT.key -CAcreateserial > SERVER.crt
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用以下方法测试证书:
测试.js
let fs = require('fs')
let https = require('https')
// HTTP server
https.createServer({ …Run Code Online (Sandbox Code Playgroud) 我正在尝试启动并运行 Spring-Boot 服务器,它通过 SSL 提供一些安全性。我按照本指南的第1 步和第 2 步获得了自签名证书,并且能够通过https. 该application.properties如下所示:
server.port=8443
server.ssl.keyStore=classpath:keystore.p12
server.ssl.keyStorePassword=youd_want_to_know
server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias=hs
Run Code Online (Sandbox Code Playgroud)
keystore.p12 是用
$ keytool -genkey -alias hs -storetype PKCS12 \
-keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
Run Code Online (Sandbox Code Playgroud)
除了密码我没有输入任何内容,所有字段都是“未知”。
但是,浏览器中的锁不是绿色的。详细信息说
站点的证书链 (net::ERR_CERT_AUTHORITY_INVALID) 存在问题。
优点:
安全 TLS 连接
与此站点的连接使用了强大的协议版本和密码套件。
安全资源
此页面上的所有资源均安全提供。
我猜在纯文本中,这意味着数据是安全传输的,但是浏览器对证书并不完全满意,因为它无法跟踪真实性。因此,我知道这不值得用于生产(现在不需要)。
但是,因为我拥有服务器并且知道我自己创建了自签名证书,所以对我来说安全吗?或者有没有办法把它变成浏览器满意的证书?我需要做什么才能使其工作以及 Sprint-Boot 配置是什么样的?
我正在尝试在 C# 程序集(目标.NET 4.0)中即时(以编程方式)生成自签名证书,以作为根 CA 生成其他证书。该证书不需要保留在 Windows 证书存储中,我会将其导出为文件。
通过阅读这个问题(特别是,@ dthorpe的答案),我决定给一个尝试CLR安全。
该CLR Security库在CngKey 类上放置了一个扩展方法来生成自签名证书,但我无法成功创建CngKeywith的实例:
var key = CngKey.Create(CngAlgorithm.Sha1); //same with Sha256, Sha512 and MD5
//or
var key = CngKey.Create(CngAlgorithm.Sha1, null, new CngKeyCreationParameters()
{
ExportPolicy = CngExportPolicies.AllowExport,
KeyUsage = CngKeyUsages.AllUsages,
KeyCreationOptions = CngKeyCreationOptions.MachineKey,
});
Run Code Online (Sandbox Code Playgroud)
这些行中的任何一行都会引发异常:
System.Security.Cryptography.CryptographicException 未处理
HResult=-2146893783
Message=不支持请求的操作。
Source=System.Core
StackTrace:
at System.Security.Cryptography.NCryptNative.CreatePersistedKey(SafeNCryptProviderHandle provider, String algorithm, String name, CngKeyCreationOptions options)
at System.Security.Cryptography.CngKey.Create(CngAlgorithm algorithm, String keyName, CngKeyCreationParameters creationParameters)
at …Run Code Online (Sandbox Code Playgroud) 我今天下午的大部分时间都在想办法解决这个问题,所以我很可能遗漏了一些简单的东西。
我需要在 Windows Server 2012 R2 上创建一个自签名证书,该证书为 SHA256、2048 位,并且四年内不会过期。
从我的搜索中,我看到 PowerShell (PS) 是可行的方法,并看到了合理数量的示例 - 其中没有一个具有我需要的一切。
例如,我尝试搜索 PS 命令 New-SelfSignedCertificate 并添加“-NotAfter”选项,但收到错误消息“找不到与参数名称‘NotAfter’匹配的参数。”
即使我在这里看到“[-NotAfter]”:https ://technet.microsoft.com/en-us/itpro/powershell/windows/pkiclient/new-selfsignedcertificate (并且该文章有 2017 年 3 月的更新)
我已经尝试了一些人们编写的 PS 脚本,这些脚本似乎可以使用 1 年以上的日期,但是它们都不适用于上述标准之一,并且无论如何都不会出现在 IIS 8.5 中我将它们绑定到一个站点(我在服务器上创建)。
服务器上的 $psversiontable 给出“PSVersion”= 5.0.10586.117
在此先感谢您的帮助!
powershell certificate self-signed iis-8 windows-server-2012-r2
我尝试maven sonar:sonar使用自签名证书在 HTTPS 连接上启动到 SonarQube 实例。Maven 给我这个错误:
[错误] 无法在项目 data.model 上执行目标 org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar (default-cli):无法执行 SonarQube:无法从服务器获取引导程序索引: sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效认证路径 -> [帮助 1]
我正在尝试在 android 中导入我的自签名 CA,以便我可以将 HTTPS POST 发送到我自签名的 Web 服务器。按照 Google Doc( https://developer.android.com/training/articles/security-config.html#ConfigCustom ) 我创建了目录 res/raw/mycertificate 并在其中添加了我的证书。创建 /res/xml 目录并将 xml 文件 network_security_config.xml 添加到清单。我在 network_security_config.xml 文件中遇到了一些麻烦,因为当我创建标签时,Android Studio 在 src 上出现错误,告诉我“缺少 src 资源”,但我将 certificate.pem 放在目录 /res/raw 中/mycertificate,并且文件夹 raw 和 mycertificate 确实存在。如何让 Android Studio 正确采用该路径文件夹?
<network-security-config>
<domain-config>
<domain includeSubdomains="true">192.168.1.200</domain>
<trust-anchors>
<certificates src="@raw/my_ca" />
</trust-anchors>
</domain-config>
Run Code Online (Sandbox Code Playgroud)
我有一个用 OpenAPI 2.0 记录的休息服务。它通过自签名 ssl 证书进行保护,该证书无法替换,因为该服务很可能会localhost在生产中运行。
我使用 swagger-codegen-maven-plugin 根据 OpenAPi 规范生成客户端。客户端似乎可以工作,但拒绝自签名证书。
底层的http库是okhttp,它能够接受自签名证书,但由于这种情况,我需要能够随时重新生成我的客户端,我无法在生成的客户端中合并必要的更改。
我怎样才能okhttp接受我的证书?
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.playground</groupId>
<artifactId>api-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<gson-fire.version>1.8.0</gson-fire.version>
<swagger-core.version>1.5.15</swagger-core.version>
<okhttp.version>2.7.5</okhttp.version>
<gson.version>2.8.1</gson.version>
<threetenbp.version>1.3.5</threetenbp.version>
<junit-version>4.12</junit-version>
<swagger-codegen-maven-plugin.version>2.3.1</swagger-codegen-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.playground</groupId>
<artifactId>playground-api</artifactId>
<version>0.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- Tag: Swagger SDK Dependencies -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-core.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency> …Run Code Online (Sandbox Code Playgroud) self-signed ×10
certificate ×4
ssl ×3
.net ×2
.net-4.0 ×1
android ×1
c# ×1
dovecot ×1
https ×1
iis-8 ×1
imap ×1
java ×1
javascript ×1
maven ×1
node.js ×1
openapi ×1
openssl ×1
php ×1
powershell ×1
signalr ×1
sonarqube ×1
spring-boot ×1
wcf ×1