无需证书的 SSL/TLS

发布于 2024-12-22 16:43:53 字数 742 浏览 1 评论 0原文

我正在开发一个宠物项目,该项目(最终完成后)将允许安全文件传输(不仅仅如此,但其余的并不是特别相关)。我想使用 OpenSSL 库,因为它似乎是最完整的免费加密库(除了 SSL/TLS 之外,我还需要支持基本的对称加密和哈希)。

我正在寻求实现一个类似于 SSH 的安全方案。基本上,用户会使用 TLSv1 (SSLv3.1) 连接到我的计算机。无论安全性如何,我都希望连接成功。然后,我希望能够检查用户使用的公钥(不是整个证书)。该密钥将与已知的公钥进行比较,如果匹配,则用户将被允许访问一组特定的命令。如果不匹配,用户可以选择使用该连接来申请将他/她的公钥添加到我的集合中,但除此之外将无法访问我的服务。

我这里对证书没有任何特别的需要。如果我可以跳过所有证书详细信息并仅使用原始加密密钥,那么对我来说会简单得多。这是因为该模型遵循信任网络模型,而不是大多数 SSL/TLS 连接使用的分层模型,因此我不需要任何 CA 或签名证书。

不幸的是,大多数 OpenSSL 的文档都不存在。我发现的所有相关文章似乎都专注于设置“标准”SSL/TLS 连接,其中服务器的证书一直被验证到一组根证书。这可能很有用,但我很难弄清楚如何启动并运行这些非传统 SSL 连接。

任何人都可以建议任何文章或文档来帮助我弄清楚如何实现这一目标吗?

(OpenSSL 的使用并不是一成不变的,如果它提供了更好的方法来实现这一点,我可以切换到另一个库,以及散列 [SHA-512] 和对称加密 [AES]。我的目标是Linux,但如果最终产品可以移植到 Windows,这样我的朋友也可以使用它,那就太好了。)

I'm working on a pet project that will (eventually, when it's done) allow for secure file transfers (there's more to it than just that, but the rest isn't particularly relevant). I'd like to use the OpenSSL library, since it seems to be the most complete free cryptography library (and I need support for basic symmetric encryption and hashing, in addition to SSL/TLS).

I'm looking to implement a security scheme similar to SSH. Basically, a user would connect to my computer with TLSv1 (SSLv3.1). I'd like the connection to succeed regardless of security. Then, I want to be able to inspect the public key (not an entire certificate) that the user used. That key would be compared against known public keys, and if it matched, then the user would be allowed to access a certain set of commands. If it didn't match, the user would have the option to use the connection to apply to have his/her public key added to my collection, but other than that would not be able to access my services.

I don't have any particular need for certificates here. It would be much simpler for me if I could just skip all the certificate details and work only with the raw encryption keys. This is because this model follows a web-of-trust model, not the hierarchical model used by most SSL/TLS connections, so I don't need any CA's or signed certificates.

Unfortunately, the documentation of most of OpenSSL is, well, nonexistent. All the relevant articles I find seem to be occupied with setting up a "standard" SSL/TLS connection, where the server's certificate is verified all the way up to a set of root certificates. This can be useful, but it's hard for me to figure out how to get these non-traditional SSL connections up and running.

Can anyone suggest any articles or documentation that might help me figure out how to accomplish this?

(The use of OpenSSL is not set in stone, and I could switch to another library if it provides a better way of accomplishing this, as well as hashing [SHA-512] and symmetric encryption [AES]. I'm aiming at targeting Linux, but it would be nice if the final product was portable to Windows so my friends could use it too.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戈亓 2024-12-29 16:43:53

为了扩展尤金的答案(我会把它作为评论,但有点长)......

FOAF+SSL 项目(后来更名为 WebID),坚持使用 X.509 证书可以使实施更容易,因为大多数 SSL/TLS 堆栈在设计时都考虑到了它们(并且他们的API 反映了这一点)。

上次我检查FOAF+SSL时,客户端仍然使用传统的PKI检查来检查服务器证书。另一种选择与 SSH 类似,是在第一次遇到公钥/证书时接受它,并在其更改时警告用户。无论如何,这或多或少就是 SSH 的工作方式(特别是,我猜很少有人在第一次看到密钥指纹时会真正检查它)。

仅考虑客户端证书的使用(尽管其中一些可以以类似的方式应用于服务器证书):

  • 大多数服务器库似乎能够处理 X.509 证书,但让您更改它们的验证方式(例如 X509TrustManager(Java 中的 X509TrustManager)。
  • 虽然在您验证客户端证书之前您无法信任客户端证书所说的任何内容,但能够嵌入一些额外信息(例如主题 DN 或主题备用名称以查看用户声称是谁)会有所帮助(a) 用户组织他们的证书,(b) 给验证者一个提示,让他们知道要寻找什么。裸露的公钥可能很难管理。
  • 许多现有的客户端工具(尤其是浏览器)在进行 SSL/TLS 客户端身份验证时使用 X.509 证书。无需做太多工作即可将客户端配置为使用自签名 X.509 证书(而不是来自 PKI 的证书)。 (支持 TLS 的 OpenPGP 的工具很少,我不确定是否有工具能够将其用作客户端证书的形式。)
  • 由于在没有外部检查的情况下您将无法信任该证书,因此它不会不管它是否是自签名的(即发行者和主题是否相同),至少假设用户不会向您发送它不同意的证书(因此不必密封)通过它自己的密钥)。这样做的结果是您可以非常轻松地构建一个服务来颁发证书。例如,浏览器内密钥生成对于不想使用 opensslkeytool 命令的用户来说很方便。 这里是一个示例服务,它将使用用户想要的 SAN 颁发证书(可能还有更多最新版本(如果您检查 FOAF+SSL/WebID 项目)。无论此类服务使用哪个私钥或颁发者名称都无关紧要,但由于浏览器是围绕传统 PKI 设计的,因此使用真正的自签名证书并不容易。

在要求特定的客户证书时也存在问题。 TLS 1.1 规范明确允许空证书颁发机构(请参阅RFC 4346),而 TLS 1.0 对此主题保持沉默。实际上,即使使用 TLS 1.0,大多数客户端工具似乎也对空列表感到满意(它们只是提供更多选择)。如果您希望系统的证书易于识别,您可以对所有这些证书使用相同的颁发者 DN,即使它们在实践中没有使用相同的私钥进行签名(同样,因为您会忽略签名)。

To expand on Eugene's answer (I would have put this as a comment, but it's a bit long)...

Having done this sort of things with the FOAF+SSL project (later renamed WebID), sticking with X.509 certificates makes the implementation easier, simply because most SSL/TLS stacks are designed with them in mind (and their API reflect this).

Last time I checked FOAF+SSL, the traditional PKI checks were still in place for the client to check the server certificate. Another option, similar to SSH, would be to accept the public key/certificate the first time you encounter it and warn the user when it changes. That's more or less the way SSH works anyway (in particular, I guess that few people actually check the key's fingerprint out of bands the first time they see it).

Considering just the client-certificate usage (although some of this could apply to server certs in a similar way):

  • Most server libraries seem to be able to process X.509 certificates, but let you change the way they are verified (e.g. X509TrustManager in Java).
  • Whilst you won't be able to trust anything the client-cert says until you have verified it otherwise, being able to embed some extra information (such as a Subject DN or Subject Alternative Name to see who the user claim to be) can help (a) the users organise their certs and (b) give a hint for the verifier to know what to look for. A bare public key can be hard to manage.
  • A number of existing client tools (especially browsers) use X.509 certificates when doing SSL/TLS client authentication. Not much needs to be done to configure a client to use a self-signed X.509 cert (as opposed to a cert from a PKI). (There are very few tools that support OpenPGP for TLS, I'm not sure any are able to use it as a form of client certificate.)
  • Since you won't be able to trust the cert without external checks, it doesn't matter whether it's self-signed or not (i.e. whether the issuer and the subject are the same), at least assuming the user wouldn't send you a cert with which it wouldn't agree (so it wouldn't have to be sealed by its own key). A consequence of that is that you can build a service to issue certs quite easily. In-browser key-generation, for example, is convenient for users who don't want to use openssl or keytool commands. Here is an example service that will issue a certificate with the SAN the user wants (there might be more recent versions if you check with the FOAF+SSL/WebID project). Whichever private key or issuer name such a service uses barely matters, but since browsers are designed around traditional PKIs, it doesn't make it easy to use really self-signed certificates.

There are also issues when it comes to asking for a specific client-certificate. The TLS 1.1 specification explicitly allows empty certification authorities (see RFC 4346), whereas the TLS 1.0 were silent on the subject. In practice, even with TLS 1.0, most client tools seem to be happy with an empty list (they'll just offer more choice). If you want your certificates for your system to be easily identifiable, you could use the same issuer DN for all these certs, even if they're not signed with the same private key in practice (again, since you would ignore the signature).

半仙 2024-12-29 16:43:53

使用自签名证书 - 这与“原始”密钥相同,但更易于管理(请参阅 这个问题关于如何在openssl中接受或不接受自签名证书)。

Use self-signed certificates - this is the same as "raw" keys but easier to manage (see this question regarding how to accept or not accept a self-signed certificate in openssl).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文