Commit 02e32b9b authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add nostore option to Create(), to keep new cert out of the DB.

parent c1502177
...@@ -207,6 +207,7 @@ sub Create($$;$) ...@@ -207,6 +207,7 @@ sub Create($$;$)
my $uuid = (exists($argref->{'uuid'}) ? $argref->{'uuid'} :undef); my $uuid = (exists($argref->{'uuid'}) ? $argref->{'uuid'} :undef);
my $url = (exists($argref->{'url'}) ? $argref->{'url'} :undef); my $url = (exists($argref->{'url'}) ? $argref->{'url'} :undef);
my $showuuid = (exists($argref->{'showuuid'})? $argref->{'showuuid'}:undef); my $showuuid = (exists($argref->{'showuuid'})? $argref->{'showuuid'}:undef);
my $nostore = (exists($argref->{'nostore'}) ? $argref->{'nostore'} :0);
# Let mkcert generate a new one. # Let mkcert generate a new one.
$uuid = "" $uuid = ""
...@@ -281,6 +282,10 @@ sub Create($$;$) ...@@ -281,6 +282,10 @@ sub Create($$;$)
if (!defined($certificate)); if (!defined($certificate));
$certificate->{'CERT'}->{'privkey'} = $privkey; $certificate->{'CERT'}->{'privkey'} = $privkey;
goto done
if ($nostore);
# #
# We need to be sure this certificate is unique, so do a table # We need to be sure this certificate is unique, so do a table
# lock and check before calling Store. # lock and check before calling Store.
...@@ -316,6 +321,7 @@ sub Create($$;$) ...@@ -316,6 +321,7 @@ sub Create($$;$)
print STDERR "Could not write new certificate to DB\n"; print STDERR "Could not write new certificate to DB\n";
goto bad; goto bad;
} }
done:
DBQueryWarn("unlock tables"); DBQueryWarn("unlock tables");
return $certificate; return $certificate;
bad: bad:
...@@ -617,6 +623,9 @@ sub LoadFromArray($$@) ...@@ -617,6 +623,9 @@ sub LoadFromArray($$@)
$self->{'CERT'}->{'created'} = undef; $self->{'CERT'}->{'created'} = undef;
$self->{'CERT'}->{'uri'} = $url; $self->{'CERT'}->{'uri'} = $url;
$self->{'CERT'}->{'urn'} = $urn; $self->{'CERT'}->{'urn'} = $urn;
# Convert URNs to objects.
$self->{'CERT'}->{'urnOBJ'} = GeniHRN->new($urn) if (defined($urn));
return $self; return $self;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment