Fedora Linux Support Community & Resources Center
  #1  
Old 27th July 2012, 09:17 AM
TheBigRed Offline
Registered User
 
Join Date: Mar 2008
Location: Germany
Posts: 295
windows_xp_2003firefox
create_ssl_certificate in rpm spec file

i am working on a bug review for a vdr plugin named vdr-live
https://bugzilla.redhat.com/show_bug.cgi?id=821233

mageia creates in his rpm spec file a ssl certificat with a rpm helper script with the name %_create_ssl_certificate
http://sophie.zarb.org/distrib/Magei...7c5f88/files/3

Code:
...
%install
rm -rf %{buildroot}
%vdr_plugin_install

install -d -m755 %{buildroot}%{_vdr_plugin_cfgdir}/%{plugin}
touch %{buildroot}%{_vdr_plugin_cfgdir}/%{plugin}/httpd.config
touch %{buildroot}%{_vdr_plugin_cfgdir}/%{plugin}/httpd.properties

install -d -m755 %{buildroot}%{_vdr_plugin_datadir}
cp -a live %{buildroot}%{_vdr_plugin_datadir}/
for dir in %plugin/*; do
	ln -s %{_vdr_plugin_datadir}/$dir %{buildroot}%{_vdr_plugin_cfgdir}/$dir
done

%clean
rm -rf %{buildroot}

%post
%_create_ssl_certificate -g vdr -b vdr-%plugin

%files -f %plugin.vdr
%defattr(-,root,root)
%doc CONTRIBUTORS HISTORY README
%dir %attr(-,vdr,vdr) %{_vdr_plugin_cfgdir}/%{plugin} %ghost %{_vdr_plugin_cfgdir}/%{plugin}/httpd.config
%ghost %{_vdr_plugin_cfgdir}/%{plugin}/httpd.properties
%{_vdr_plugin_cfgdir}/%{plugin}/css
%{_vdr_plugin_cfgdir}/%{plugin}/img
%{_vdr_plugin_cfgdir}/%{plugin}/js
%{_vdr_plugin_cfgdir}/%{plugin}/themes
%{_vdr_plugin_datadir}/%{plugin}
...

is there a rpm helper script like the %_create_ssl_certificate in mageia for fedora ?
http://svnweb.mageia.org/soft/rpm/rp...p&pathrev=2081

Code:
#!/bin/sh
# $Id: create-ssl-certificate 255059 2009-03-29 21:29:57Z guillomovitch $
# helper script for creating ssl certificates

while [ $# -gt 0 ]; do
    case $1 in
	   -g) group=$2; shift 2;;
	   -b) bundle="true"; shift;;
	    *) args=( ${args[@]:-} $1 ); shift;;
      esac
done

pkg=${args[0]}	# name of the package
num=${args[1]}	# number of packages installed
srv=${args[2]}	# name of the service

if [ -z "$pkg" -o -z "$num" -o -z "$srv" ]; then
    echo "usage: $0 [-g <group>] [-b] <pkg name> <num installed> <service>" 1>&2
    exit 1
fi

if [ ! -f /etc/pki/tls/private/$srv.pem ]; then 
    # default values
    host=$(hostname)
    KEY_LENGTH=1024
    CERT_DAYS=365
    EMAIL_ADDRESS=root@$host
    COMMON_NAME=$host
    ORGANISATIONAL_UNIT_NAME="default $srv cert for $host"

    # source configuration
    if [ -f /etc/sysconfig/ssl ]; then
	. /etc/sysconfig/ssl
    fi

    conffile=/tmp/$$
    keyfile=/etc/pki/tls/private/$srv.pem
    if [ "$bundle" == true ]; then
	certfile=$keyfile
    else
	certfile=/etc/pki/tls/certs/$srv.pem
    fi

    # create a temporary configuration file
    cat > $conffile <<EOF
default_bits            = $KEY_LENGTH
encrypt_key             = no
prompt                  = no
distinguished_name      = req_dn
req_extensions          = req_ext

[ req_dn ] 
commonName              = $COMMON_NAME
organizationalUnitName  = $ORGANISATIONAL_UNIT_NAME
emailAddress            = $EMAIL_ADDRESS

[ req_ext ]
basicConstraints        = CA:FALSE
EOF
    
    # generate certificates
    openssl req -new -x509 -days $CERT_DAYS \
        -config $conffile \
        -keyout $keyfile \
        -out $certfile >/dev/null

    # enforce strict perms on key
    if [ -n "$group" ]; then
	chmod 640 $keyfile
	chgrp $group $keyfile
    else
	chmod 600 $keyfile
    fi
fi
may this can be helpful ?
https://fedoraproject.org/wiki/Archi...Server/OpenSSL
http://odysseus.x-tnd.be/fedora/prosody/prosody.spec


How do i create a ssl certificate in a rpm spec file for fedora ?

Last edited by TheBigRed; 27th July 2012 at 11:36 AM.
Reply With Quote
Reply

Tags
createsslcertificate, file, rpm, spec

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Need help with RPM spec file Hlingler Programming & Packaging 3 18th January 2011 12:24 PM
How to have an RPM replace another in the SPEC file? uncholowapo Using Fedora 0 30th September 2009 06:48 AM
I need help with my FCEUX spec file uncholowapo Gamers' Lounge 4 26th December 2008 06:06 PM
Viewing the spec file of RPM“s eggsy85 Programming & Packaging 4 4th August 2005 05:36 PM
About the spec file in emacs-21.4-2.src.rpm AlaxMAX Using Fedora 2 19th April 2005 09:41 AM


Current GMT-time: 16:33 (Friday, 21-11-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Yoshida-kasugacho Photos - Cerquilho Photos on Instagram - Chusovoy