Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Elixir): fix warnings emitted from v1.17.0 #71

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/x509/certificate/extension.ex
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ defmodule X509.Certificate.Extension do

iex> X509.Certificate.Extension.subject_alt_name(["www.example.com", "example.com"])
{:Extension, {2, 5, 29, 17}, false,
[dNSName: 'www.example.com', dNSName: 'example.com']}
[dNSName: ~c"www.example.com", dNSName: ~c"example.com"]}

iex> X509.Certificate.Extension.subject_alt_name(emailAddress: 'user@example.com')
iex> X509.Certificate.Extension.subject_alt_name(emailAddress: ~c"user@example.com")
{:Extension, {2, 5, 29, 17}, false,
[emailAddress: 'user@example.com']}
[emailAddress: ~c"user@example.com"]}
"""
@spec subject_alt_name([san_value()]) :: t()
def subject_alt_name(value) do
Expand Down Expand Up @@ -289,7 +289,7 @@ defmodule X509.Certificate.Extension do
{:Extension, {2, 5, 29, 31}, false,
[
{:DistributionPoint,
{:fullName, [uniformResourceIdentifier: 'http://crl.example.org/root.crl']},
{:fullName, [uniformResourceIdentifier: ~c"http://crl.example.org/root.crl"]},
:asn1_NOVALUE, :asn1_NOVALUE}
]}
"""
Expand Down
6 changes: 3 additions & 3 deletions lib/x509/certificate/validity.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ defmodule X509.Certificate.Validity do
iex> {:ok, not_before, 0} = DateTime.from_iso8601("2018-01-01T00:00:00Z")
iex> {:ok, not_after, 0} = DateTime.from_iso8601("2018-12-31T23:59:59Z")
iex> X509.Certificate.Validity.new(not_before, not_after)
{:Validity, {:utcTime, '180101000000Z'}, {:utcTime, '181231235959Z'}}
{:Validity, {:utcTime, ~c"180101000000Z"}, {:utcTime, ~c"181231235959Z"}}

iex> {:ok, not_before, 0} = DateTime.from_iso8601("2051-01-01T00:00:00Z")
iex> {:ok, not_after, 0} = DateTime.from_iso8601("2051-12-31T23:59:59Z")
iex> X509.Certificate.Validity.new(not_before, not_after)
{:Validity, {:generalTime, '20510101000000Z'},
{:generalTime, '20511231235959Z'}}
{:Validity, {:generalTime, ~c"20510101000000Z"},
{:generalTime, ~c"20511231235959Z"}}
"""
@spec new(DateTime.t(), DateTime.t()) :: t()
def new(%DateTime{} = not_before, %DateTime{} = not_after) do
Expand Down
4 changes: 2 additions & 2 deletions lib/x509/date_time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule X509.DateTime do
def utc_time(%DateTime{} = datetime) do
iso = DateTime.to_iso8601(datetime, :basic)
[_, date, time] = Regex.run(~r/^\d\d(\d{6})T(\d{6})(?:\.\d+)?Z$/, iso)
'#{date}#{time}Z'
~c"#{date}#{time}Z"
end

# Builds ASN.1 GeneralTime as charlist
Expand All @@ -40,7 +40,7 @@ defmodule X509.DateTime do
def general_time(%DateTime{} = datetime) do
iso = DateTime.to_iso8601(datetime, :basic)
[_, date, time] = Regex.run(~r/^(\d{8})T(\d{6})(?:\.\d+)?Z$/, iso)
'#{date}#{time}Z'
~c"#{date}#{time}Z"
end

def to_datetime({:utcTime, time}) do
Expand Down
4 changes: 2 additions & 2 deletions lib/x509/private_key.ex
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ defmodule X509.PrivateKey do
def from_pem(pem, opts \\ []) do
password =
opts
|> Keyword.get(:password, '')
|> Keyword.get(:password, ~c"")
|> to_charlist()

pem
Expand Down Expand Up @@ -307,6 +307,6 @@ defmodule X509.PrivateKey do
end

defp cipher_info() do
{'DES-EDE3-CBC', :crypto.strong_rand_bytes(8)}
{~c"DES-EDE3-CBC", :crypto.strong_rand_bytes(8)}
end
end
2 changes: 1 addition & 1 deletion lib/x509/rdn_sequence.ex
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ defmodule X509.RDNSequence do
?A..?Z |> Enum.into([]),
?a..?z |> Enum.into([]),
?0..?9 |> Enum.into([]),
' \'()+,-./:=?'
~c" '()+,-./:=?"
]
|> List.flatten()

Expand Down
8 changes: 4 additions & 4 deletions test/x509/certificate/extension_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ defmodule X509.Certificate.ExtensionTest do
assert certs.server
|> X509.Certificate.extension(:subject_alt_name)
|> extension(:extnValue) ==
[dNSName: '*.tools.ietf.org', dNSName: 'tools.ietf.org']
[dNSName: ~c"*.tools.ietf.org", dNSName: ~c"tools.ietf.org"]
end

test "crl_distribution_points", %{certs: certs} do
Expand All @@ -73,7 +73,7 @@ defmodule X509.Certificate.ExtensionTest do
{:DistributionPoint,
{:fullName,
[
uniformResourceIdentifier: 'http://crl.starfieldtech.com/sfig2s1-128.crl'
uniformResourceIdentifier: ~c"http://crl.starfieldtech.com/sfig2s1-128.crl"
]}, :asn1_NOVALUE, :asn1_NOVALUE}
]
end
Expand All @@ -83,10 +83,10 @@ defmodule X509.Certificate.ExtensionTest do
|> X509.Certificate.extension(:authority_info_access)
|> extension(:extnValue) == [
{:AccessDescription, {1, 3, 6, 1, 5, 5, 7, 48, 1},
{:uniformResourceIdentifier, 'http://ocsp.starfieldtech.com/'}},
{:uniformResourceIdentifier, ~c"http://ocsp.starfieldtech.com/"}},
{:AccessDescription, {1, 3, 6, 1, 5, 5, 7, 48, 2},
{:uniformResourceIdentifier,
'http://certificates.starfieldtech.com/repository/sfig2.crt'}}
~c"http://certificates.starfieldtech.com/repository/sfig2.crt"}}
]
end

Expand Down
2 changes: 1 addition & 1 deletion test/x509/certificate/validity_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule X509.Certificate.ValidityTest do
validity = X509.Certificate.Validity.new(not_before, not_after)
assert <<der::binary>> = :public_key.der_encode(:Validity, validity)

assert {:Validity, {:utcTime, '220101000000Z'}, {:generalTime, '20511231235959Z'}} =
assert {:Validity, {:utcTime, ~c"220101000000Z"}, {:generalTime, ~c"20511231235959Z"}} =
:public_key.der_decode(:Validity, der)
end
end
2 changes: 1 addition & 1 deletion test/x509/certificate_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ defmodule X509.CertificateTest do
|> X509.Certificate.extension(:key_usage)
|> extension(:extnValue)

assert [rfc822Name: 'end.entity@example.com'] =
assert [rfc822Name: ~c"end.entity@example.com"] =
cert2
|> X509.Certificate.extension(:subject_alt_name)
|> extension(:extnValue)
Expand Down
Loading
Loading