<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 30 Jan 2020, at 21:38, Douglas Morris via openssl-users <<a href="mailto:openssl-users@openssl.org" class="">openssl-users@openssl.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div class="ydpc44dcd6dyahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div class=""><div dir="ltr" data-setdir="false" class="">I am trying to implement automated domain certificate renewal. A certificate signing request is sent to an ACME server and on success a certificate is returned. I'd like to be able to call OpenSSL to make a new key and then make a new certificate signing request just like the old one except for the replacement key pair file.</div><div dir="ltr" data-setdir="false" class=""><span class=""><br class=""></span></div><div dir="ltr" data-setdir="false" class=""><span class="">I suppose the complete information beyond the new key data is available both in the old crs and 
the old certificate. I'm looking at the 
manpages of OpenSSL subcommands 'req' and 'x509'. The openssl x509 
option '<span class="">-x509toreq</span>' gave me a momentary rush of hope, but then I read about the '<span class="">-signkey</span>' option, which seems to be exclusively about self-signing.</span><br class=""></div><div dir="ltr" data-setdir="false" class=""><br class=""></div><div dir="ltr" data-setdir="false" class="">Is 'cloning' the csr or cert. information semantically logical? Is it possible with OpenSSL?<br class=""></div><div dir="ltr" data-setdir="false" class=""><br class=""></div><div dir="ltr" data-setdir="false" class="">If I can't reliably extract the relevant data from the old csr or old certification, I suppose I must do it as usual with a dedicated config file and the '-batch' option:</div><div dir="ltr" data-setdir="false" class="">     openssl req -key <key> -<span class="">new -config <config.ini> -outform PEM -out <outfile></span> -batch</div></div></div></div></div></blockquote><div><br class=""></div><div>openssl x509 -x509toreq should do the trick</div><div><br class=""></div><div>E.g.</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">             </span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(12, 255, 0); background-color: rgba(255, 255, 255, 0.901961);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">      </span># generate test cert</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(12, 255, 0); background-color: rgba(255, 255, 255, 0.901961);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>openssl req -x509 -new -subj /CN=foo -nodes -keyout x.key > x.crt</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(12, 255, 0); background-color: rgba(255, 255, 255, 0.901961);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>openssl x509 -in x.crt -noout -text</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(12, 255, 0); background-color: rgba(255, 255, 255, 0.901961);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(12, 255, 0); background-color: rgba(255, 255, 255, 0.901961);" class=""><span class="Apple-tab-span" style="white-space:pre">   </span># turn test cert in a request</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(12, 255, 0); background-color: rgba(255, 255, 255, 0.901961);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>openssl x509 -x509toreq -signkey x.key < x.crt</span></div><div><br class=""></div><div>Dw</div><div><br class=""></div></div></body></html>