projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix numeric -newkey args.
[openssl.git]
/
apps
/
req.c
diff --git
a/apps/req.c
b/apps/req.c
index 50802f52ca269426cdeda174ba73124f88334a46..f37616feffe910088fcc7133c87673389135eba2 100644
(file)
--- a/
apps/req.c
+++ b/
apps/req.c
@@
-221,13
+221,16
@@
char **argv;
}
else if (strcmp(*argv,"-newkey") == 0)
{
}
else if (strcmp(*argv,"-newkey") == 0)
{
+ int is_numeric;
+
if (--argc < 1) goto bad;
p= *(++argv);
if (--argc < 1) goto bad;
p= *(++argv);
- i
f ((strncmp("rsa:",p,4) == 0) ||
-
((p[0] >= '0') && (p[0] <= '9'))
)
+ i
s_numeric = p[0] >= '0' && p[0] <= '9';
+
if (strncmp("rsa:",p,4) == 0 || is_numeric
)
{
pkey_type=TYPE_RSA;
{
pkey_type=TYPE_RSA;
- p+=4;
+ if(!is_numeric)
+ p+=4;
newkey= atoi(p);
}
else
newkey= atoi(p);
}
else
@@
-357,12
+360,14
@@
bad:
#ifndef MONOLITH
/* Lets load up our environment a little */
#ifndef MONOLITH
/* Lets load up our environment a little */
- p=getenv("SSLEAY_CONF");
+ p=getenv("OPENSSL_CONF");
+ if (p == NULL)
+ p=getenv("SSLEAY_CONF");
if (p == NULL)
{
strcpy(config_name,X509_get_default_cert_area());
strcat(config_name,"/lib/");
if (p == NULL)
{
strcpy(config_name,X509_get_default_cert_area());
strcat(config_name,"/lib/");
- strcat(config_name,
SSLEAY
_CONF);
+ strcat(config_name,
OPENSSL
_CONF);
p=config_name;
}
default_config_file=p;
p=config_name;
}
default_config_file=p;
@@
-622,6
+627,7
@@
loop:
}
if (x509)
{
}
if (x509)
{
+ EVP_PKEY *tmppkey;
if ((x509ss=X509_new()) == NULL) goto end;
/* don't set the version number, for starters
if ((x509ss=X509_new()) == NULL) goto end;
/* don't set the version number, for starters
@@
-637,7
+643,9
@@
loop:
(long)60*60*24*days);
X509_set_subject_name(x509ss,
X509_REQ_get_subject_name(req));
(long)60*60*24*days);
X509_set_subject_name(x509ss,
X509_REQ_get_subject_name(req));
- X509_set_pubkey(x509ss,X509_REQ_get_pubkey(req));
+ tmppkey = X509_REQ_get_pubkey(req);
+ X509_set_pubkey(x509ss,tmppkey);
+ EVP_PKEY_free(tmppkey);
if (!(i=X509_sign(x509ss,pkey,digest)))
goto end;
if (!(i=X509_sign(x509ss,pkey,digest)))
goto end;
@@
-661,7
+669,10
@@
loop:
}
i=X509_REQ_verify(req,pkey);
}
i=X509_REQ_verify(req,pkey);
- if (tmp) pkey=NULL;
+ if (tmp) {
+ EVP_PKEY_free(pkey);
+ pkey=NULL;
+ }
if (i < 0)
{
if (i < 0)
{