This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/main by this push:
new 0be49f2bd Convert common name to an IP address tuple before generating
certificate
0be49f2bd is described below
commit 0be49f2bd52a88f1aaf86ea9afcf44d80748bb96
Author: Jiahui Li <[email protected]>
AuthorDate: Wed Nov 18 16:30:04 2026 -0600
Convert common name to an IP address tuple before generating certificate
- OTP 26.2.3+ has modified the [hostname verification method][ref].
If the `Common Name` is an IP address, convert it into an IP adderss
tuple before generating the certificate.
- Bump dependency libraries.
- Update README.md.
[ref]:
https://github.com/erlang/otp/commit/d348bd7f1fb901d5632f0063dcd2c362af817661
---
src/couch_dist/README.md | 72 +++++++++++++++++++++++-------------------
src/couch_dist/certs/certs.exs | 10 ++++--
2 files changed, 47 insertions(+), 35 deletions(-)
diff --git a/src/couch_dist/README.md b/src/couch_dist/README.md
index aabf4a5d9..03b2b9c5f 100644
--- a/src/couch_dist/README.md
+++ b/src/couch_dist/README.md
@@ -96,67 +96,73 @@ You can run CouchDB with `--enable-tls` mode, which will
automatically generate
vm.args, certificates, and configuration files.
```bash
-./configure --dev --spidermonkey-version 91 && make && ./dev/run -t
-./configure --dev --spidermonkey-version 91 && make && ./dev/run --enable-tls
+# Enable custom TLS distribution when starting CouchDB
+./configure --dev && make && ./dev/run --enable-tls
+# Or using the short flag `-t`
+./configure --dev && make && ./dev/run -t
+# Verify in another terminal
./dev/remsh-tls
([email protected])1> net_kernel:nodes_info().
-{ok,[{'[email protected]',
- [{owner,<0.679.0>},
+{ok,[{'[email protected]',
+ [{owner,<0.420.0>},
{state,up},
{address,
- {net_address,{{127,0,0,1},55013},"127.0.0.1",tls,inet}},
+ {net_address,{{127,0,0,1},51814},"127.0.0.1",tls,inet}},
{type,normal},
- {in,150},
- {out,147}]},
- {'[email protected]',
- [{owner,<0.655.0>},
+ {in,39},
+ {out,38}]},
+ {'[email protected]',
+ [{owner,<0.422.0>},
{state,up},
{address,
- {net_address,{{127,0,0,1},55011},"127.0.0.1",tls,inet}},
+ {net_address,{{127,0,0,1},51813},"127.0.0.1",tls,inet}},
{type,normal},
- {in,181},
- {out,196}]},
- {'[email protected]',
- [{owner,<0.8558.0>},
+ {in,40},
+ {out,39}]},
+ {'[email protected]',
+ [{owner,<0.778.0>},
{state,up},
{address,
- {net_address,{{127,0,0,1},55075},"127.0.0.1",tls,inet}},
+ {net_address,{{127,0,0,1},51837},"127.0.0.1",tls,inet}},
{type,hidden},
- {in,10},
- {out,15}]}]}
+ {in,13},
+ {out,18}]}]}
```
-You can also set specific nodes to use TCP:
+You can also set specific nodes to use TCP only:
```bash
-./configure --dev --spidermonkey-version 91 && make && ./dev/run -t --no-tls
[email protected]
-./configure --dev --spidermonkey-version 91 && make && ./dev/run -t --no-tls
node2,node3
+# Specify [email protected] to use TCP only
+./configure --dev && make && ./dev/run -t --no-tls [email protected]
+# Or use short node names
+./configure --dev && make && ./dev/run -t --no-tls node2,node3
+# Verify in another terminal
./dev/remsh-tls
([email protected])1> net_kernel:nodes_info().
{ok,[{'[email protected]',
- [{owner,<0.456.0>},
+ [{owner,<0.402.0>},
{state,up},
{address,
- {net_address,{{127,0,0,1},55170},"127.0.0.1",tcp,inet}},
+ {net_address,{{127,0,0,1},51750},"127.0.0.1",tcp,inet}},
{type,normal},
- {in,145},
- {out,164}]},
+ {in,55},
+ {out,50}]},
{'[email protected]',
- [{owner,<0.461.0>},
+ [{owner,<0.408.0>},
{state,up},
{address,
- {net_address,{{127,0,0,1},55172},"127.0.0.1",tcp,inet}},
+ {net_address,{{127,0,0,1},51751},"127.0.0.1",tcp,inet}},
{type,normal},
- {in,141},
- {out,169}]},
- {'[email protected]',
- [{owner,<0.1418.0>},
+ {in,67},
+ {out,49}]},
+ {'[email protected]',
+ [{owner,<0.794.0>},
{state,up},
{address,
- {net_address,{{127,0,0,1},55203},"127.0.0.1",tls,inet}},
+ {net_address,{{127,0,0,1},51779},"127.0.0.1",tls,inet}},
{type,hidden},
- {in,10},
- {out,15}]}]}
+ {in,29},
+ {out,50}]}]}
```
diff --git a/src/couch_dist/certs/certs.exs b/src/couch_dist/certs/certs.exs
index 7ce09dbba..6af540ce1 100644
--- a/src/couch_dist/certs/certs.exs
+++ b/src/couch_dist/certs/certs.exs
@@ -2,7 +2,7 @@
# credo:disable-for-this-file
# Important: run this with the wrapper script, so that umask is set correctly.
-Mix.install([{:x509, "~> 0.8.3"}, {:optimus, "~> 0.2"}])
+Mix.install([{:x509, "~> 0.9.2"}, {:optimus, "~> 0.6.1"}])
defmodule Certs do
def main(argv) do
@@ -70,6 +70,12 @@ defmodule Certs do
X509.RDNSequence.new(subject)
|> X509.RDNSequence.get_attr(:commonName)
+ ipAddress =
+ case :inet.parse_address(to_charlist(commonName)) do
+ {:ok, ip} -> [{:iPAddress, ip |> Tuple.to_list() |>
:erlang.list_to_binary()}]
+ _ -> []
+ end
+
import X509.Certificate.Extension
%X509.Certificate.Template{
@@ -82,7 +88,7 @@ defmodule Certs do
ext_key_usage: ext_key_usage([:serverAuth, :clientAuth]),
subject_key_identifier: true,
authority_key_identifier: true,
- subject_alt_name: subject_alt_name([commonName])
+ subject_alt_name: subject_alt_name([commonName | ipAddress])
]
}
end